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

Function TestParseContext_CancelledContext

pkg/sql/parser/context_test.go:102–121  ·  view source on GitHub ↗

TestParseContext_CancelledContext verifies that cancellation is detected

(t *testing.T)

Source from the content-addressed store, hash-verified

100
101// TestParseContext_CancelledContext verifies that cancellation is detected
102func TestParseContext_CancelledContext(t *testing.T) {
103 ctx, cancel := context.WithCancel(context.Background())
104 cancel() // Cancel immediately
105
106 sql := "SELECT * FROM users"
107 tokens := tokenizeSQL(t, sql)
108
109 p := NewParser()
110 defer p.Release()
111
112 ast, err := p.ParseContext(ctx, tokens)
113
114 if err != context.Canceled {
115 t.Errorf("Expected context.Canceled error, got: %v", err)
116 }
117
118 if ast != nil {
119 t.Error("Expected nil AST when context is cancelled")
120 }
121}
122
123// TestParseContext_Timeout verifies that timeout is respected
124func TestParseContext_Timeout(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected