============================================================ AlterStatement pool tests ============================================================
(t *testing.T)
| 768 | // ============================================================ |
| 769 | |
| 770 | func TestAlterStatementPool(t *testing.T) { |
| 771 | t.Run("Get returns non-nil", func(t *testing.T) { |
| 772 | stmt := GetAlterStatement() |
| 773 | if stmt == nil { |
| 774 | t.Fatal("GetAlterStatement() returned nil") |
| 775 | } |
| 776 | PutAlterStatement(stmt) |
| 777 | }) |
| 778 | |
| 779 | t.Run("Put nil is safe", func(t *testing.T) { |
| 780 | PutAlterStatement(nil) |
| 781 | }) |
| 782 | |
| 783 | t.Run("Fields zeroed after Put", func(t *testing.T) { |
| 784 | stmt := GetAlterStatement() |
| 785 | stmt.Type = AlterTypeTable |
| 786 | stmt.Name = "users" |
| 787 | stmt.Operation = &AlterTableOperation{ |
| 788 | Type: AddColumn, |
| 789 | ColumnName: &Ident{Name: "age"}, |
| 790 | } |
| 791 | |
| 792 | PutAlterStatement(stmt) |
| 793 | |
| 794 | if stmt.Type != 0 { |
| 795 | t.Errorf("Type not cleared, got %v", stmt.Type) |
| 796 | } |
| 797 | if stmt.Name != "" { |
| 798 | t.Errorf("Name not cleared, got %q", stmt.Name) |
| 799 | } |
| 800 | if stmt.Operation != nil { |
| 801 | t.Error("Operation not cleared") |
| 802 | } |
| 803 | }) |
| 804 | |
| 805 | t.Run("Pool roundtrip reuse", func(t *testing.T) { |
| 806 | stmt1 := GetAlterStatement() |
| 807 | stmt1.Name = "orders" |
| 808 | PutAlterStatement(stmt1) |
| 809 | |
| 810 | stmt2 := GetAlterStatement() |
| 811 | if stmt2.Name != "" { |
| 812 | t.Errorf("Reused statement not clean, Name=%q", stmt2.Name) |
| 813 | } |
| 814 | PutAlterStatement(stmt2) |
| 815 | }) |
| 816 | } |
| 817 | |
| 818 | // ============================================================ |
| 819 | // ReleaseAST mixed DML + DDL test |
nothing calls this directly
no test coverage detected