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

Function TestRenderSetOperation

pkg/formatter/render_test.go:399–418  ·  view source on GitHub ↗

─── SET OPERATIONS ──────────────────────────────────────────────────────────

(t *testing.T)

Source from the content-addressed store, hash-verified

397// ─── SET OPERATIONS ──────────────────────────────────────────────────────────
398
399func TestRenderSetOperation(t *testing.T) {
400 s := &ast.SetOperation{
401 Left: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "a"}}, From: []ast.TableReference{{Name: "t1"}}},
402 Right: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "b"}}, From: []ast.TableReference{{Name: "t2"}}},
403 Operator: "UNION",
404 All: true,
405 }
406 result := fmtStmt(s, ast.ReadableStyle())
407 if !strings.Contains(result, "UNION ALL") {
408 t.Errorf("expected UNION ALL, got: %s", result)
409 }
410 if !strings.HasSuffix(strings.TrimSpace(result), ";") {
411 t.Error("ReadableStyle should add semicolon")
412 }
413
414 compact := fmtStmt(s, ast.CompactStyle())
415 if strings.Contains(compact, "\n") {
416 t.Errorf("compact should be single line: %s", compact)
417 }
418}
419
420func TestRenderSetOperation_Nil(t *testing.T) {
421 var s *ast.SetOperation

Callers

nothing calls this directly

Calls 5

ReadableStyleFunction · 0.92
CompactStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected