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

Function TestDeleteStatementPool

pkg/sql/ast/pool_test.go:112–144  ·  view source on GitHub ↗

Test DeleteStatement pool

(t *testing.T)

Source from the content-addressed store, hash-verified

110
111// Test DeleteStatement pool
112func TestDeleteStatementPool(t *testing.T) {
113 t.Run("Get and Put", func(t *testing.T) {
114 // Get from pool
115 stmt := GetDeleteStatement()
116 if stmt == nil {
117 t.Fatal("GetDeleteStatement() returned nil")
118 }
119
120 // Use it
121 stmt.TableName = "users"
122 stmt.Where = &BinaryExpression{
123 Left: &Identifier{Name: "id"},
124 Operator: "=",
125 Right: &LiteralValue{Value: "10"},
126 }
127
128 // Return to pool
129 PutDeleteStatement(stmt)
130
131 // Verify it was cleaned
132 if stmt.TableName != "" {
133 t.Errorf("TableName not cleared, got %v", stmt.TableName)
134 }
135 if stmt.Where != nil {
136 t.Errorf("Where not cleared, got %v", stmt.Where)
137 }
138 })
139
140 t.Run("Put nil statement", func(t *testing.T) {
141 // Should not panic
142 PutDeleteStatement(nil)
143 })
144}
145
146// Test UpdateExpression pool
147func TestUpdateExpressionPool(t *testing.T) {

Callers

nothing calls this directly

Calls 4

GetDeleteStatementFunction · 0.85
PutDeleteStatementFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected