MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestConvertStatement

Function TestConvertStatement

cmd/gosqlx/cmd/parser_cmd_test.go:295–320  ·  view source on GitHub ↗

TestConvertStatement tests statement conversion

(t *testing.T)

Source from the content-addressed store, hash-verified

293
294// TestConvertStatement tests statement conversion
295func TestConvertStatement(t *testing.T) {
296 // Test with a simple SELECT statement
297 var outBuf, errBuf bytes.Buffer
298 parser := NewParser(&outBuf, &errBuf, CLIParserOptions{Format: "table"})
299
300 result, err := parser.Parse("SELECT * FROM users WHERE active = true")
301 if err != nil {
302 t.Fatalf("Failed to parse: %v", err)
303 }
304 defer ast.ReleaseAST(result.AST)
305
306 if len(result.AST.Statements) == 0 {
307 t.Fatal("Expected at least one statement")
308 }
309
310 display := convertStatement(result.AST.Statements[0])
311
312 if display.Type == "" {
313 t.Error("Expected type to be set")
314 }
315
316 // Should have details for SELECT statement
317 if display.Details == nil {
318 t.Error("Expected details for SELECT statement")
319 }
320}
321
322// TestParserOptionsFromConfig tests configuration merging
323func TestParserOptionsFromConfig(t *testing.T) {

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.95
ReleaseASTFunction · 0.92
convertStatementFunction · 0.85
NewParserFunction · 0.70
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected