| 84 | } |
| 85 | |
| 86 | func TestDropSequenceStatement_ToSQL(t *testing.T) { |
| 87 | tests := []struct { |
| 88 | name string |
| 89 | stmt *ast.DropSequenceStatement |
| 90 | want string |
| 91 | }{ |
| 92 | { |
| 93 | name: "basic", |
| 94 | stmt: &ast.DropSequenceStatement{Name: &ast.Identifier{Name: "seq_orders"}}, |
| 95 | want: "DROP SEQUENCE seq_orders", |
| 96 | }, |
| 97 | { |
| 98 | name: "if exists", |
| 99 | stmt: &ast.DropSequenceStatement{Name: &ast.Identifier{Name: "seq_orders"}, IfExists: true}, |
| 100 | want: "DROP SEQUENCE IF EXISTS seq_orders", |
| 101 | }, |
| 102 | { |
| 103 | name: "nil name does not panic", |
| 104 | stmt: &ast.DropSequenceStatement{}, |
| 105 | want: "DROP SEQUENCE ", |
| 106 | }, |
| 107 | } |
| 108 | for _, tt := range tests { |
| 109 | t.Run(tt.name, func(t *testing.T) { |
| 110 | got := tt.stmt.ToSQL() |
| 111 | if got != tt.want { |
| 112 | t.Errorf("ToSQL() = %q, want %q", got, tt.want) |
| 113 | } |
| 114 | }) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func TestAlterSequenceStatement_ToSQL(t *testing.T) { |
| 119 | tests := []struct { |