runQueryTest runs a single query test
(t *testing.T, test QueryTest)
| 312 | |
| 313 | // runQueryTest runs a single query test |
| 314 | func 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 |
| 365 | func runQueryTests(t *testing.T, tests []QueryTest) { |
no test coverage detected