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

Function TestParser_DisplayAST_JSON

cmd/gosqlx/cmd/parser_cmd_test.go:117–143  ·  view source on GitHub ↗

TestParser_DisplayAST_JSON tests JSON output format

(t *testing.T)

Source from the content-addressed store, hash-verified

115
116// TestParser_DisplayAST_JSON tests JSON output format
117func TestParser_DisplayAST_JSON(t *testing.T) {
118 var outBuf, errBuf bytes.Buffer
119 parser := NewParser(&outBuf, &errBuf, CLIParserOptions{
120 Format: "json",
121 })
122
123 result, err := parser.Parse("SELECT * FROM users")
124 if err != nil {
125 t.Fatalf("Unexpected error: %v", err)
126 }
127 defer ast.ReleaseAST(result.AST)
128
129 err = parser.Display(result)
130 if err != nil {
131 t.Fatalf("Failed to display: %v", err)
132 }
133
134 output := outBuf.String()
135 if output == "" {
136 t.Error("Expected JSON output but got empty string")
137 }
138
139 // Basic JSON validation
140 if !strings.Contains(output, "{") || !strings.Contains(output, "}") {
141 t.Error("Output doesn't look like valid JSON")
142 }
143}
144
145// TestParser_DisplayAST_YAML tests YAML output format
146func TestParser_DisplayAST_YAML(t *testing.T) {

Callers

nothing calls this directly

Calls 7

ParseMethod · 0.95
DisplayMethod · 0.95
ReleaseASTFunction · 0.92
NewParserFunction · 0.70
FatalfMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected