()
| 34 | } |
| 35 | |
| 36 | func main() { |
| 37 | initialization.Initialize(nil, doltgresservercfg.DefaultServerConfig()) |
| 38 | rootFolder, err := utils.GetRootFolder() |
| 39 | if err != nil { |
| 40 | fmt.Printf("%s\n", err.Error()) |
| 41 | return |
| 42 | } |
| 43 | rootFolder = rootFolder.MoveRoot("testing/generation/function_coverage") |
| 44 | |
| 45 | // Sort the strings for determinism, since range iteration on maps is non-deterministic |
| 46 | functionNames := make([]string, 0, len(framework.Catalog)) |
| 47 | for functionName := range framework.Catalog { |
| 48 | functionNames = append(functionNames, functionName) |
| 49 | } |
| 50 | sort.Strings(functionNames) |
| 51 | |
| 52 | for _, functionName := range functionNames { |
| 53 | var assertions []Assertion |
| 54 | |
| 55 | utils.PrintSectionMarker(functionName, '+', 80) |
| 56 | |
| 57 | FunctionLoop: |
| 58 | for _, function := range framework.Catalog[functionName] { |
| 59 | var literalGeneratorParams []utils.StatementGenerator |
| 60 | literalGeneratorParams = append(literalGeneratorParams, utils.Text(functionName+"(")) |
| 61 | for i, paramType := range function.GetParameters() { |
| 62 | if i > 0 { |
| 63 | literalGeneratorParams = append(literalGeneratorParams, utils.Text(", ")) |
| 64 | } |
| 65 | if generator, ok := valueMappings[paramType.ID]; ok { |
| 66 | literalGeneratorParams = append(literalGeneratorParams, generator) |
| 67 | } else { |
| 68 | fmt.Printf("missing support for functions with the parameter type: `%s`\n", paramType.String()) |
| 69 | continue FunctionLoop |
| 70 | } |
| 71 | } |
| 72 | literalGeneratorParams = append(literalGeneratorParams, utils.Text(")")) |
| 73 | literalGenerator := utils.Collection( |
| 74 | utils.Text("SELECT"), |
| 75 | utils.Collection(literalGeneratorParams...), |
| 76 | utils.Text(";"), |
| 77 | ) |
| 78 | |
| 79 | randomInts, err := utils.GenerateRandomInts(500, literalGenerator.Permutations()) |
| 80 | if err != nil { |
| 81 | fmt.Println(err.Error()) |
| 82 | continue FunctionLoop |
| 83 | } |
| 84 | for _, randomInt := range randomInts { |
| 85 | literalGenerator.SetConsumeIterations(randomInt) |
| 86 | assertion := Assertion{ |
| 87 | Stmt: literalGenerator.String(), |
| 88 | Error: false, |
| 89 | } |
| 90 | result, _, err := QueryPostgres(assertion.Stmt) |
| 91 | if err != nil { |
| 92 | assertion.Error = true |
| 93 | } else { |
nothing calls this directly
no test coverage detected