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

Function TestAlterSequenceStatement_ToSQL

pkg/sql/ast/ast_sequence_test.go:118–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestAlterSequenceStatement_ToSQL(t *testing.T) {
119 tests := []struct {
120 name string
121 stmt *ast.AlterSequenceStatement
122 want string
123 }{
124 {
125 name: "restart bare",
126 stmt: &ast.AlterSequenceStatement{
127 Name: &ast.Identifier{Name: "s"},
128 Options: ast.SequenceOptions{Restart: true},
129 },
130 want: "ALTER SEQUENCE s RESTART",
131 },
132 {
133 name: "restart with value",
134 stmt: &ast.AlterSequenceStatement{
135 Name: &ast.Identifier{Name: "s"},
136 Options: ast.SequenceOptions{
137 RestartWith: &ast.LiteralValue{Value: "1"},
138 },
139 },
140 want: "ALTER SEQUENCE s RESTART WITH 1",
141 },
142 {
143 name: "nil name does not panic",
144 stmt: &ast.AlterSequenceStatement{},
145 want: "ALTER SEQUENCE ",
146 },
147 }
148 for _, tt := range tests {
149 t.Run(tt.name, func(t *testing.T) {
150 got := tt.stmt.ToSQL()
151 if got != tt.want {
152 t.Errorf("ToSQL() = %q, want %q", got, tt.want)
153 }
154 })
155 }
156}
157
158func TestSequencePool_RoundTrip(t *testing.T) {
159 s := ast.NewCreateSequenceStatement()

Callers

nothing calls this directly

Calls 3

RunMethod · 0.80
ErrorfMethod · 0.65
ToSQLMethod · 0.45

Tested by

no test coverage detected