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

Function TestInspector

pkg/sql/ast/visitor_test.go:84–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestInspector(t *testing.T) {
85 // Create a simple AST
86 ast := &AST{
87 Statements: []Statement{
88 &SelectStatement{
89 Columns: []Expression{
90 &Identifier{Name: "id"},
91 },
92 TableName: "users",
93 },
94 },
95 }
96
97 var identifiers []*Identifier
98 Inspect(ast, func(n Node) bool {
99 if id, ok := n.(*Identifier); ok {
100 identifiers = append(identifiers, id)
101 }
102 return true
103 })
104
105 if len(identifiers) != 1 {
106 t.Errorf("expected 1 identifier, got %d", len(identifiers))
107 }
108 if identifiers[0].Name != "id" {
109 t.Errorf("expected identifier name 'id', got '%s'", identifiers[0].Name)
110 }
111}
112
113func TestVisitFunc(t *testing.T) {
114 ast := &AST{

Callers

nothing calls this directly

Calls 2

InspectFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected