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

Function TestSelectStatementPool

pkg/sql/ast/ast_test.go:64–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestSelectStatementPool(t *testing.T) {
65 // Test getting a SelectStatement
66 stmt1 := GetSelectStatement()
67 if stmt1 == nil {
68 t.Fatal("expected non-nil SelectStatement")
69 }
70 if len(stmt1.Columns) != 0 {
71 t.Errorf("expected empty columns, got %d", len(stmt1.Columns))
72 }
73 if len(stmt1.OrderBy) != 0 {
74 t.Errorf("expected empty order by, got %d", len(stmt1.OrderBy))
75 }
76
77 // Add some expressions
78 stmt1.Columns = append(stmt1.Columns, &Identifier{Name: "id"})
79 stmt1.Where = &BinaryExpression{
80 Left: &Identifier{Name: "id"},
81 Operator: "=",
82 Right: &Identifier{Name: "1"},
83 }
84
85 // Release back to pool
86 PutSelectStatement(stmt1)
87
88 // Test getting another SelectStatement reuses the pool
89 stmt2 := GetSelectStatement()
90 if stmt2 == nil {
91 t.Fatal("expected non-nil SelectStatement")
92 }
93 if len(stmt2.Columns) != 0 {
94 t.Errorf("expected empty columns after reset, got %d", len(stmt2.Columns))
95 }
96 if stmt2.Where != nil {
97 t.Error("expected nil Where after reset")
98 }
99 PutSelectStatement(stmt2)
100}
101
102func TestIdentifierPool(t *testing.T) {
103 // Test getting an Identifier

Callers

nothing calls this directly

Calls 4

GetSelectStatementFunction · 0.85
PutSelectStatementFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected