MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestProtocolErrors

Function TestProtocolErrors

tests/integration/protocol_test.go:345–388  ·  view source on GitHub ↗

TestProtocolErrors tests error handling

(t *testing.T)

Source from the content-addressed store, hash-verified

343
344// TestProtocolErrors tests error handling
345func TestProtocolErrors(t *testing.T) {
346 t.Run("syntax_error", func(t *testing.T) {
347 _, err := testHarness.DuckgresDB.Query("SELEC 1") // typo
348 if err == nil {
349 t.Error("Expected syntax error")
350 }
351 })
352
353 t.Run("table_not_found", func(t *testing.T) {
354 _, err := testHarness.DuckgresDB.Query("SELECT * FROM nonexistent_table_xyz")
355 if err == nil {
356 t.Error("Expected table not found error")
357 }
358 })
359
360 t.Run("column_not_found", func(t *testing.T) {
361 _, err := testHarness.DuckgresDB.Query("SELECT nonexistent_column FROM users")
362 if err == nil {
363 t.Error("Expected column not found error")
364 }
365 })
366
367 t.Run("type_error", func(t *testing.T) {
368 _, err := testHarness.DuckgresDB.Query("SELECT 'not a number'::INTEGER")
369 if err == nil {
370 t.Error("Expected type error")
371 }
372 })
373
374 t.Run("error_recovery", func(t *testing.T) {
375 // After an error, connection should still be usable
376 _, _ = testHarness.DuckgresDB.Query("SELECT * FROM nonexistent") // This should error
377
378 // But this should work
379 var val int
380 err := testHarness.DuckgresDB.QueryRow("SELECT 1").Scan(&val)
381 if err != nil {
382 t.Errorf("Query after error failed: %v", err)
383 }
384 if val != 1 {
385 t.Errorf("Expected 1, got %d", val)
386 }
387 })
388}
389
390// TestProtocolDataTypes tests that various data types are correctly transmitted
391func TestProtocolDataTypes(t *testing.T) {

Callers

nothing calls this directly

Calls 4

RunMethod · 0.65
QueryMethod · 0.65
ScanMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected