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

Function TestInsertStatementPool

pkg/sql/ast/pool_test.go:24–65  ·  view source on GitHub ↗

Test InsertStatement pool

(t *testing.T)

Source from the content-addressed store, hash-verified

22
23// Test InsertStatement pool
24func TestInsertStatementPool(t *testing.T) {
25 t.Run("Get and Put", func(t *testing.T) {
26 // Get from pool
27 stmt := GetInsertStatement()
28 if stmt == nil {
29 t.Fatal("GetInsertStatement() returned nil")
30 }
31
32 // Use it
33 stmt.TableName = "users"
34 stmt.Columns = []Expression{
35 &Identifier{Name: "name"},
36 &Identifier{Name: "email"},
37 }
38 // Values is now [][]Expression for multi-row support
39 stmt.Values = [][]Expression{
40 {
41 &LiteralValue{Value: "John"},
42 &LiteralValue{Value: "john@example.com"},
43 },
44 }
45
46 // Return to pool
47 PutInsertStatement(stmt)
48
49 // Verify it was cleaned
50 if stmt.TableName != "" {
51 t.Errorf("TableName not cleared, got %v", stmt.TableName)
52 }
53 if len(stmt.Columns) != 0 {
54 t.Errorf("Columns not cleared, len = %d", len(stmt.Columns))
55 }
56 if len(stmt.Values) != 0 {
57 t.Errorf("Values not cleared, len = %d", len(stmt.Values))
58 }
59 })
60
61 t.Run("Put nil statement", func(t *testing.T) {
62 // Should not panic
63 PutInsertStatement(nil)
64 })
65}
66
67// Test UpdateStatement pool
68func TestUpdateStatementPool(t *testing.T) {

Callers

nothing calls this directly

Calls 4

GetInsertStatementFunction · 0.85
PutInsertStatementFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected