--------------------------------------------------------------------------- Dialect gate tests - reject invalid cross-dialect syntax --------------------------------------------------------------------------- TestRejectUnknownDialect ensures that ParseWithDialect and ValidateWithDialect return error
(t *testing.T)
| 152 | // TestRejectUnknownDialect ensures that ParseWithDialect and ValidateWithDialect |
| 153 | // return errors for dialect names that don't exist. |
| 154 | func TestRejectUnknownDialect(t *testing.T) { |
| 155 | _, err := ParseWithDialect("SELECT 1", keywords.SQLDialect("fakesql")) |
| 156 | if err == nil { |
| 157 | t.Fatal("expected error for unknown dialect 'fakesql', got nil") |
| 158 | } |
| 159 | if !containsAny(err.Error(), "unknown", "dialect") { |
| 160 | t.Errorf("error should mention 'unknown' or 'dialect', got: %v", err) |
| 161 | } |
| 162 | |
| 163 | err = ValidateWithDialect("SELECT 1", keywords.SQLDialect("fakesql")) |
| 164 | if err == nil { |
| 165 | t.Fatal("expected error from ValidateWithDialect for unknown dialect") |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // TestIsValidDialect covers the IsValidDialect helper. |
| 170 | func TestIsValidDialect(t *testing.T) { |
nothing calls this directly
no test coverage detected