Test UpdateStatement pool
(t *testing.T)
| 66 | |
| 67 | // Test UpdateStatement pool |
| 68 | func TestUpdateStatementPool(t *testing.T) { |
| 69 | t.Run("Get and Put", func(t *testing.T) { |
| 70 | // Get from pool |
| 71 | stmt := GetUpdateStatement() |
| 72 | if stmt == nil { |
| 73 | t.Fatal("GetUpdateStatement() returned nil") |
| 74 | } |
| 75 | |
| 76 | // Use it |
| 77 | stmt.TableName = "users" |
| 78 | stmt.Assignments = []UpdateExpression{ |
| 79 | { |
| 80 | Column: &Identifier{Name: "email"}, |
| 81 | Value: &LiteralValue{Value: "new@example.com"}, |
| 82 | }, |
| 83 | } |
| 84 | stmt.Where = &BinaryExpression{ |
| 85 | Left: &Identifier{Name: "id"}, |
| 86 | Operator: "=", |
| 87 | Right: &LiteralValue{Value: "1"}, |
| 88 | } |
| 89 | |
| 90 | // Return to pool |
| 91 | PutUpdateStatement(stmt) |
| 92 | |
| 93 | // Verify it was cleaned |
| 94 | if stmt.TableName != "" { |
| 95 | t.Errorf("TableName not cleared, got %v", stmt.TableName) |
| 96 | } |
| 97 | if len(stmt.Assignments) != 0 { |
| 98 | t.Errorf("Updates not cleared, len = %d", len(stmt.Assignments)) |
| 99 | } |
| 100 | if stmt.Where != nil { |
| 101 | t.Errorf("Where not cleared, got %v", stmt.Where) |
| 102 | } |
| 103 | }) |
| 104 | |
| 105 | t.Run("Put nil statement", func(t *testing.T) { |
| 106 | // Should not panic |
| 107 | PutUpdateStatement(nil) |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | // Test DeleteStatement pool |
| 112 | func TestDeleteStatementPool(t *testing.T) { |
nothing calls this directly
no test coverage detected