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

Function runQueryTest

tests/integration/setup_test.go:314–362  ·  view source on GitHub ↗

runQueryTest runs a single query test

(t *testing.T, test QueryTest)

Source from the content-addressed store, hash-verified

312
313// runQueryTest runs a single query test
314func runQueryTest(t *testing.T, test QueryTest) {
315 t.Helper()
316
317 // Check centralized skip list first
318 skipIfKnown(t)
319
320 if test.Skip != "" {
321 t.Skipf("Skipping: %s", test.Skip)
322 return
323 }
324
325 if test.DuckgresOnly || skipPostgresCompare {
326 // Only test against Duckgres
327 result, err := ExecuteQuery(testHarness.DuckgresDB, test.Query)
328 if err != nil {
329 t.Fatalf("Failed to execute query: %v", err)
330 }
331 if test.ExpectError {
332 if result.Error == nil {
333 t.Errorf("Expected error but query succeeded")
334 }
335 } else {
336 if result.Error != nil {
337 t.Errorf("Query failed: %v", result.Error)
338 }
339 }
340 return
341 }
342
343 // Compare PostgreSQL and Duckgres
344 opts := test.Options
345 if opts.FloatTolerance == 0 {
346 opts = DefaultCompareOptions()
347 }
348
349 result := CompareQueries(testHarness.PostgresDB, testHarness.DuckgresDB, test.Query, opts)
350
351 if test.ExpectError {
352 if result.PGError == nil && result.DGError == nil {
353 t.Errorf("Expected error but both queries succeeded")
354 }
355 return
356 }
357
358 if !result.Match {
359 t.Errorf("Query results do not match:\n PostgreSQL rows: %d\n Duckgres rows: %d\n Differences:\n %s",
360 result.PGRowCount, result.DGRowCount, formatDifferences(result.Differences))
361 }
362}
363
364// runQueryTests runs multiple query tests
365func runQueryTests(t *testing.T, tests []QueryTest) {

Callers 1

runQueryTestsFunction · 0.85

Calls 5

skipIfKnownFunction · 0.85
ExecuteQueryFunction · 0.85
DefaultCompareOptionsFunction · 0.85
CompareQueriesFunction · 0.85
formatDifferencesFunction · 0.85

Tested by

no test coverage detected