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

Function TestRenderCase_Simple

pkg/formatter/render_test.go:851–869  ·  view source on GitHub ↗

─── CASE expression ─────────────────────────────────────────────────────────

(t *testing.T)

Source from the content-addressed store, hash-verified

849// ─── CASE expression ─────────────────────────────────────────────────────────
850
851func TestRenderCase_Simple(t *testing.T) {
852 expr := &ast.CaseExpression{
853 Value: &ast.Identifier{Name: "status"},
854 WhenClauses: []ast.WhenClause{
855 {Condition: &ast.LiteralValue{Value: "1"}, Result: &ast.LiteralValue{Value: "'active'"}},
856 {Condition: &ast.LiteralValue{Value: "2"}, Result: &ast.LiteralValue{Value: "'inactive'"}},
857 },
858 ElseClause: &ast.LiteralValue{Value: "'unknown'"},
859 }
860 result := fmtExpr(expr, ast.ReadableStyle())
861 for _, kw := range []string{"CASE", "WHEN", "THEN", "ELSE", "END"} {
862 if !strings.Contains(result, kw) {
863 t.Errorf("expected %q in: %s", kw, result)
864 }
865 }
866 if !strings.Contains(result, "status") {
867 t.Errorf("expected simple CASE value in: %s", result)
868 }
869}
870
871func TestRenderCase_Searched(t *testing.T) {
872 expr := &ast.CaseExpression{

Callers

nothing calls this directly

Calls 3

ReadableStyleFunction · 0.92
fmtExprFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected