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

Function TestParseContext_ConcurrentCalls

pkg/sql/parser/context_test.go:282–313  ·  view source on GitHub ↗

TestParseContext_ConcurrentCalls verifies thread safety with concurrent context-aware calls

(t *testing.T)

Source from the content-addressed store, hash-verified

280
281// TestParseContext_ConcurrentCalls verifies thread safety with concurrent context-aware calls
282func TestParseContext_ConcurrentCalls(t *testing.T) {
283 const numGoroutines = 10
284
285 ctx := context.Background()
286 sql := "SELECT id, name, email FROM users WHERE active = true"
287 tokens := tokenizeSQL(t, sql)
288
289 done := make(chan bool, numGoroutines)
290
291 for i := 0; i < numGoroutines; i++ {
292 go func(id int) {
293 p := NewParser()
294 defer p.Release()
295
296 ast, err := p.ParseContext(ctx, tokens)
297 if err != nil {
298 t.Errorf("Goroutine %d: ParseContext() error = %v", id, err)
299 }
300
301 if ast == nil {
302 t.Errorf("Goroutine %d: Expected AST but got nil", id)
303 }
304
305 done <- true
306 }(i)
307 }
308
309 // Wait for all goroutines to complete
310 for i := 0; i < numGoroutines; i++ {
311 <-done
312 }
313}
314
315// TestParseContext_BackwardCompatibility verifies non-context method still works
316func TestParseContext_BackwardCompatibility(t *testing.T) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected