TestParseContext_ConcurrentCalls verifies thread safety with concurrent context-aware calls
(t *testing.T)
| 280 | |
| 281 | // TestParseContext_ConcurrentCalls verifies thread safety with concurrent context-aware calls |
| 282 | func 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 |
| 316 | func TestParseContext_BackwardCompatibility(t *testing.T) { |
nothing calls this directly
no test coverage detected