MCPcopy Create free account
hub / github.com/dolthub/doltgresql / RunTests

Function RunTests

testing/generation/command_docs/output/framework_test.go:106–138  ·  view source on GitHub ↗

RunTests runs the given collection of QueryParses tests.

(t *testing.T, tests []QueryParses)

Source from the content-addressed store, hash-verified

104// RunTests runs the given collection of QueryParses tests.
105
106func RunTests(t *testing.T, tests []QueryParses) {
107 for _, test := range tests {
108 t.Run(test.String(), func(t *testing.T) {
109 statements, err := parser.Parse(test.String())
110 if !test.ShouldParse() {
111 if err == nil && len(statements) > 0 {
112 t.Fatal("Query now parses, please upgrade the type to `Parses`")
113 }
114 return
115 }
116 require.NoError(t, err, "Regression, query previously parsed")
117 require.Truef(t, len(statements) > 0, "Regression, query previously produced a Postgres AST")
118 for _, statement := range statements {
119 vitessAST, err := func() (vitessAST sqlparser.Statement, err error) {
120 defer func() {
121 if recoverVal := recover(); recoverVal != nil {
122 vitessAST = nil
123 }
124 }()
125 return ast.Convert(statement)
126 }()
127 if !test.ShouldConvert() {
128 if err == nil && vitessAST != nil {
129 t.Fatalf("Query %s now converts, please upgrade the type to `Converts`", test.String())
130 }
131 return
132 }
133 assert.NoError(t, err, "Regression, query previously converted from a Postgres AST to a Vitess AST")
134 assert.NotNil(t, vitessAST, "Regression, query now returns a nil Vitess AST")
135 }
136 })
137 }
138}
139
140// Regex which checks for the line beginning with Unimplemented, Parses, or Converts
141var testStatementRegex = regexp.MustCompile(`^(\s*)(Unimplemented|Parses|Converts)\(`)

Callers 15

TestAlterIndexFunction · 0.85
TestSavepointFunction · 0.85
TestRollbackPreparedFunction · 0.85
TestListenFunction · 0.85
TestDropProcedureFunction · 0.85
TestDropOperatorFamilyFunction · 0.85
TestDropDatabaseFunction · 0.85
TestAnalyzeFunction · 0.85
TestAlterTriggerFunction · 0.85
TestAlterLargeObjectFunction · 0.85

Calls 7

ParseFunction · 0.92
ConvertFunction · 0.92
RunMethod · 0.80
FatalMethod · 0.80
StringMethod · 0.65
ShouldParseMethod · 0.65
ShouldConvertMethod · 0.65

Tested by

no test coverage detected