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

Function TestParser_DisplayAST_Table

cmd/gosqlx/cmd/parser_cmd_test.go:170–203  ·  view source on GitHub ↗

TestParser_DisplayAST_Table tests table output format

(t *testing.T)

Source from the content-addressed store, hash-verified

168
169// TestParser_DisplayAST_Table tests table output format
170func TestParser_DisplayAST_Table(t *testing.T) {
171 var outBuf, errBuf bytes.Buffer
172 parser := NewParser(&outBuf, &errBuf, CLIParserOptions{
173 Format: "table",
174 })
175
176 result, err := parser.Parse("SELECT * FROM users")
177 if err != nil {
178 t.Fatalf("Unexpected error: %v", err)
179 }
180 defer ast.ReleaseAST(result.AST)
181
182 err = parser.Display(result)
183 if err != nil {
184 t.Fatalf("Failed to display: %v", err)
185 }
186
187 output := outBuf.String()
188 if output == "" {
189 t.Error("Expected table output but got empty string")
190 }
191
192 // Check for expected table elements
193 expectedElements := []string{
194 "AST Structure",
195 "Statements",
196 }
197
198 for _, elem := range expectedElements {
199 if !strings.Contains(output, elem) {
200 t.Errorf("Expected output to contain '%s', but it doesn't", elem)
201 }
202 }
203}
204
205// TestParser_DisplayTokens tests token display
206func TestParser_DisplayTokens(t *testing.T) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected