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

Function TestFormat_DDL_KeywordCase

pkg/formatter/render_ddl_test.go:177–196  ·  view source on GitHub ↗

TestFormat_DDL_KeywordCase verifies that DDL formatter respects keyword casing options.

(t *testing.T)

Source from the content-addressed store, hash-verified

175
176// TestFormat_DDL_KeywordCase verifies that DDL formatter respects keyword casing options.
177func TestFormat_DDL_KeywordCase(t *testing.T) {
178 sql := "DROP SEQUENCE myseq"
179 tree, err := gosqlx.ParseWithDialect(sql, keywords.DialectMariaDB)
180 if err != nil {
181 t.Fatalf("Parse error: %v", err)
182 }
183 stmt := tree.Statements[0].(*ast.DropSequenceStatement)
184
185 upperOpts := ast.FormatOptions{KeywordCase: ast.KeywordUpper}
186 result := formatter.FormatStatement(stmt, upperOpts)
187 if !strings.Contains(result, "DROP SEQUENCE") {
188 t.Errorf("expected uppercase keywords, got: %q", result)
189 }
190
191 lowerOpts := ast.FormatOptions{KeywordCase: ast.KeywordLower}
192 result = formatter.FormatStatement(stmt, lowerOpts)
193 if !strings.Contains(result, "drop sequence") {
194 t.Errorf("expected lowercase keywords, got: %q", result)
195 }
196}

Callers

nothing calls this directly

Calls 4

ParseWithDialectFunction · 0.92
FormatStatementFunction · 0.92
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected