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

Function TestRenderSelect_Readable

pkg/formatter/render_test.go:65–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestRenderSelect_Readable(t *testing.T) {
66 stmt := &ast.SelectStatement{
67 Columns: []ast.Expression{&ast.Identifier{Name: "a"}, &ast.Identifier{Name: "b"}},
68 From: []ast.TableReference{{Name: "users"}},
69 Where: &ast.BinaryExpression{
70 Left: &ast.Identifier{Name: "active"},
71 Operator: "=",
72 Right: &ast.LiteralValue{Value: "true"},
73 },
74 }
75
76 result := fmtStmt(stmt, ast.ReadableStyle())
77 lines := strings.Split(result, "\n")
78 if len(lines) < 3 {
79 t.Errorf("ReadableStyle should have multiple lines, got %d: %s", len(lines), result)
80 }
81 if !strings.HasPrefix(lines[0], "SELECT") {
82 t.Errorf("first line should start with SELECT, got: %s", lines[0])
83 }
84 if !strings.Contains(result, "FROM") {
85 t.Errorf("should contain uppercase FROM, got: %s", result)
86 }
87 if !strings.Contains(result, "WHERE") {
88 t.Errorf("should contain uppercase WHERE, got: %s", result)
89 }
90 if !strings.HasSuffix(strings.TrimSpace(result), ";") {
91 t.Errorf("ReadableStyle should end with semicolon, got: %s", result)
92 }
93}
94
95func TestRenderSelect_LowercaseKeywords(t *testing.T) {
96 stmt := &ast.SelectStatement{

Callers

nothing calls this directly

Calls 3

ReadableStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected