MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestRejectUnknownDialect

Function TestRejectUnknownDialect

pkg/sql/parser/dialect_test.go:154–167  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Dialect gate tests - reject invalid cross-dialect syntax --------------------------------------------------------------------------- TestRejectUnknownDialect ensures that ParseWithDialect and ValidateWithDialect return error

(t *testing.T)

Source from the content-addressed store, hash-verified

152// TestRejectUnknownDialect ensures that ParseWithDialect and ValidateWithDialect
153// return errors for dialect names that don't exist.
154func 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.
170func TestIsValidDialect(t *testing.T) {

Callers

nothing calls this directly

Calls 6

SQLDialectTypeAlias · 0.92
containsAnyFunction · 0.85
ValidateWithDialectFunction · 0.85
ParseWithDialectFunction · 0.70
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected