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

Function TestParseContext_BackwardCompatibility

pkg/sql/parser/context_test.go:316–346  ·  view source on GitHub ↗

TestParseContext_BackwardCompatibility verifies non-context method still works

(t *testing.T)

Source from the content-addressed store, hash-verified

314
315// TestParseContext_BackwardCompatibility verifies non-context method still works
316func TestParseContext_BackwardCompatibility(t *testing.T) {
317 sql := "SELECT * FROM users"
318 tokens := tokenizeSQL(t, sql)
319
320 p := NewParser()
321 defer p.Release()
322
323 // Test old non-context method
324 ast1, err1 := p.Parse(tokens)
325 if err1 != nil {
326 t.Fatalf("Parse() error = %v", err1)
327 }
328
329 // Test new context method with background context
330 ast2, err2 := p.ParseContext(context.Background(), tokens)
331 if err2 != nil {
332 t.Fatalf("ParseContext() error = %v", err2)
333 }
334
335 // Both should produce ASTs
336 if ast1 == nil || ast2 == nil {
337 t.Error("Expected ASTs from both methods")
338 return
339 }
340
341 // Both should have same number of statements
342 if len(ast1.Statements) != len(ast2.Statements) {
343 t.Errorf("Statement count mismatch: Parse()=%d, ParseContext()=%d",
344 len(ast1.Statements), len(ast2.Statements))
345 }
346}
347
348// TestParseContext_ErrorHandling verifies proper error handling
349func TestParseContext_ErrorHandling(t *testing.T) {

Callers

nothing calls this directly

Calls 8

ReleaseMethod · 0.95
ParseMethod · 0.95
ParseContextMethod · 0.95
tokenizeSQLFunction · 0.85
NewParserFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected