============================================================ DropStatement pool tests ============================================================
(t *testing.T)
| 517 | // ============================================================ |
| 518 | |
| 519 | func TestDropStatementPool(t *testing.T) { |
| 520 | t.Run("Get returns non-nil", func(t *testing.T) { |
| 521 | stmt := GetDropStatement() |
| 522 | if stmt == nil { |
| 523 | t.Fatal("GetDropStatement() returned nil") |
| 524 | } |
| 525 | PutDropStatement(stmt) |
| 526 | }) |
| 527 | |
| 528 | t.Run("Put nil is safe", func(t *testing.T) { |
| 529 | PutDropStatement(nil) |
| 530 | }) |
| 531 | |
| 532 | t.Run("Fields zeroed after Put", func(t *testing.T) { |
| 533 | stmt := GetDropStatement() |
| 534 | stmt.ObjectType = "TABLE" |
| 535 | stmt.IfExists = true |
| 536 | stmt.Names = append(stmt.Names, "users", "orders") |
| 537 | stmt.CascadeType = "CASCADE" |
| 538 | |
| 539 | PutDropStatement(stmt) |
| 540 | |
| 541 | if stmt.ObjectType != "" { |
| 542 | t.Errorf("ObjectType not cleared, got %q", stmt.ObjectType) |
| 543 | } |
| 544 | if stmt.IfExists { |
| 545 | t.Error("IfExists not cleared") |
| 546 | } |
| 547 | if len(stmt.Names) != 0 { |
| 548 | t.Errorf("Names not cleared, len=%d", len(stmt.Names)) |
| 549 | } |
| 550 | if stmt.CascadeType != "" { |
| 551 | t.Errorf("CascadeType not cleared, got %q", stmt.CascadeType) |
| 552 | } |
| 553 | }) |
| 554 | |
| 555 | t.Run("Pool roundtrip reuse", func(t *testing.T) { |
| 556 | stmt1 := GetDropStatement() |
| 557 | stmt1.ObjectType = "VIEW" |
| 558 | PutDropStatement(stmt1) |
| 559 | |
| 560 | stmt2 := GetDropStatement() |
| 561 | if stmt2.ObjectType != "" { |
| 562 | t.Errorf("Reused statement not clean, ObjectType=%q", stmt2.ObjectType) |
| 563 | } |
| 564 | PutDropStatement(stmt2) |
| 565 | }) |
| 566 | } |
| 567 | |
| 568 | // ============================================================ |
| 569 | // TruncateStatement pool tests |
nothing calls this directly
no test coverage detected