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

Function TestFormatAST_MultiStatement

pkg/formatter/render_test.go:1035–1056  ·  view source on GitHub ↗

─── FormatAST ───────────────────────────────────────────────────────────────

(t *testing.T)

Source from the content-addressed store, hash-verified

1033// ─── FormatAST ───────────────────────────────────────────────────────────────
1034
1035func TestFormatAST_MultiStatement(t *testing.T) {
1036 a := &ast.AST{
1037 Statements: []ast.Statement{
1038 &ast.SelectStatement{
1039 Columns: []ast.Expression{&ast.Identifier{Name: "a"}},
1040 From: []ast.TableReference{{Name: "t1"}},
1041 },
1042 &ast.SelectStatement{
1043 Columns: []ast.Expression{&ast.Identifier{Name: "b"}},
1044 From: []ast.TableReference{{Name: "t2"}},
1045 },
1046 },
1047 }
1048
1049 result := formatter.FormatAST(a, ast.CompactStyle())
1050 if !strings.Contains(result, "SELECT a FROM t1") {
1051 t.Errorf("should contain first statement, got: %s", result)
1052 }
1053 if !strings.Contains(result, "SELECT b FROM t2") {
1054 t.Errorf("should contain second statement, got: %s", result)
1055 }
1056}
1057
1058func TestFormatAST_Nil(t *testing.T) {
1059 result := formatter.FormatAST(nil, ast.CompactStyle())

Callers

nothing calls this directly

Calls 3

FormatASTFunction · 0.92
CompactStyleFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected