TestDialectRegistry tests the AllDialects and DialectKeywords registry functions.
(t *testing.T)
| 455 | |
| 456 | // TestDialectRegistry tests the AllDialects and DialectKeywords registry functions. |
| 457 | func TestDialectRegistry(t *testing.T) { |
| 458 | t.Run("AllDialects returns expected list", func(t *testing.T) { |
| 459 | dialects := AllDialects() |
| 460 | if len(dialects) == 0 { |
| 461 | t.Fatal("AllDialects() returned empty slice") |
| 462 | } |
| 463 | |
| 464 | // Check that all expected dialects are present |
| 465 | expectedDialects := map[SQLDialect]bool{ |
| 466 | DialectGeneric: false, |
| 467 | DialectPostgreSQL: false, |
| 468 | DialectMySQL: false, |
| 469 | DialectMariaDB: false, |
| 470 | DialectSQLServer: false, |
| 471 | DialectOracle: false, |
| 472 | DialectSQLite: false, |
| 473 | DialectSnowflake: false, |
| 474 | DialectBigQuery: false, |
| 475 | DialectRedshift: false, |
| 476 | DialectClickHouse: false, |
| 477 | } |
| 478 | |
| 479 | for _, d := range dialects { |
| 480 | if _, ok := expectedDialects[d]; !ok { |
| 481 | t.Errorf("Unexpected dialect %q in AllDialects()", d) |
| 482 | } |
| 483 | expectedDialects[d] = true |
| 484 | } |
| 485 | |
| 486 | for d, found := range expectedDialects { |
| 487 | if !found { |
| 488 | t.Errorf("Expected dialect %q not found in AllDialects()", d) |
| 489 | } |
| 490 | } |
| 491 | }) |
| 492 | |
| 493 | t.Run("DialectKeywords for Snowflake", func(t *testing.T) { |
| 494 | kws := DialectKeywords(DialectSnowflake) |
| 495 | if kws == nil { |
| 496 | t.Fatal("DialectKeywords(DialectSnowflake) returned nil") |
| 497 | } |
| 498 | if len(kws) == 0 { |
| 499 | t.Fatal("DialectKeywords(DialectSnowflake) returned empty slice") |
| 500 | } |
| 501 | }) |
| 502 | |
| 503 | t.Run("DialectKeywords for MySQL", func(t *testing.T) { |
| 504 | kws := DialectKeywords(DialectMySQL) |
| 505 | if kws == nil { |
| 506 | t.Fatal("DialectKeywords(DialectMySQL) returned nil") |
| 507 | } |
| 508 | }) |
| 509 | |
| 510 | t.Run("DialectKeywords for PostgreSQL", func(t *testing.T) { |
| 511 | kws := DialectKeywords(DialectPostgreSQL) |
| 512 | if kws == nil { |
| 513 | t.Fatal("DialectKeywords(DialectPostgreSQL) returned nil") |
| 514 | } |
nothing calls this directly
no test coverage detected