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

Function TestParser_DisplayTree

cmd/gosqlx/cmd/parser_cmd_test.go:235–265  ·  view source on GitHub ↗

TestParser_DisplayTree tests tree visualization

(t *testing.T)

Source from the content-addressed store, hash-verified

233
234// TestParser_DisplayTree tests tree visualization
235func TestParser_DisplayTree(t *testing.T) {
236 var outBuf, errBuf bytes.Buffer
237 parser := NewParser(&outBuf, &errBuf, CLIParserOptions{
238 Format: "table",
239 TreeView: true,
240 })
241
242 result, err := parser.Parse("SELECT * FROM users WHERE id = 1")
243 if err != nil {
244 t.Fatalf("Unexpected error: %v", err)
245 }
246 defer ast.ReleaseAST(result.AST)
247
248 err = parser.Display(result)
249 if err != nil {
250 t.Fatalf("Failed to display tree: %v", err)
251 }
252
253 output := outBuf.String()
254 if output == "" {
255 t.Error("Expected tree output but got empty string")
256 }
257
258 // Check for tree visualization elements
259 if !strings.Contains(output, "AST Tree") {
260 t.Error("Expected 'AST Tree' in output")
261 }
262 if !strings.Contains(output, "├──") && !strings.Contains(output, "└──") {
263 t.Error("Expected tree box-drawing characters in output")
264 }
265}
266
267// TestParser_ComplexQuery tests parsing complex queries
268func TestParser_ComplexQuery(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