Skip to content

Commit ae4dd18

Browse files
committed
extra unit test checks
1 parent 731df3c commit ae4dd18

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

go/sql/parser_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestParseAlterStatement(t *testing.T) {
2222
parser := NewAlterTableParser()
2323
err := parser.ParseAlterStatement(statement)
2424
test.S(t).ExpectNil(err)
25+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
2526
test.S(t).ExpectFalse(parser.HasNonTrivialRenames())
2627
}
2728

@@ -30,6 +31,7 @@ func TestParseAlterStatementTrivialRename(t *testing.T) {
3031
parser := NewAlterTableParser()
3132
err := parser.ParseAlterStatement(statement)
3233
test.S(t).ExpectNil(err)
34+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
3335
test.S(t).ExpectFalse(parser.HasNonTrivialRenames())
3436
test.S(t).ExpectEquals(len(parser.columnRenameMap), 1)
3537
test.S(t).ExpectEquals(parser.columnRenameMap["ts"], "ts")
@@ -40,6 +42,7 @@ func TestParseAlterStatementTrivialRenames(t *testing.T) {
4042
parser := NewAlterTableParser()
4143
err := parser.ParseAlterStatement(statement)
4244
test.S(t).ExpectNil(err)
45+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
4346
test.S(t).ExpectFalse(parser.HasNonTrivialRenames())
4447
test.S(t).ExpectEquals(len(parser.columnRenameMap), 2)
4548
test.S(t).ExpectEquals(parser.columnRenameMap["ts"], "ts")
@@ -61,6 +64,7 @@ func TestParseAlterStatementNonTrivial(t *testing.T) {
6164
parser := NewAlterTableParser()
6265
err := parser.ParseAlterStatement(statement)
6366
test.S(t).ExpectNil(err)
67+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
6468
renames := parser.GetNonTrivialRenames()
6569
test.S(t).ExpectEquals(len(renames), 2)
6670
test.S(t).ExpectEquals(renames["i"], "count")
@@ -136,6 +140,7 @@ func TestParseAlterStatementDroppedColumns(t *testing.T) {
136140
statement := "drop column b, drop key c_idx, drop column `d`"
137141
err := parser.ParseAlterStatement(statement)
138142
test.S(t).ExpectNil(err)
143+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
139144
test.S(t).ExpectEquals(len(parser.droppedColumns), 2)
140145
test.S(t).ExpectTrue(parser.droppedColumns["b"])
141146
test.S(t).ExpectTrue(parser.droppedColumns["d"])
@@ -181,6 +186,7 @@ func TestParseAlterStatementRenameTable(t *testing.T) {
181186
statement := "drop column b, rename as something_else"
182187
err := parser.ParseAlterStatement(statement)
183188
test.S(t).ExpectNil(err)
189+
test.S(t).ExpectEquals(parser.alterStatementOptions, statement)
184190
test.S(t).ExpectTrue(parser.isRenameTable)
185191
}
186192
{
@@ -208,6 +214,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
208214
test.S(t).ExpectNil(err)
209215
test.S(t).ExpectEquals(parser.explicitSchema, "")
210216
test.S(t).ExpectEquals(parser.explicitTable, "")
217+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
211218
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
212219
}
213220
{
@@ -217,6 +224,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
217224
test.S(t).ExpectNil(err)
218225
test.S(t).ExpectEquals(parser.explicitSchema, "")
219226
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
227+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
220228
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
221229
}
222230
{
@@ -226,6 +234,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
226234
test.S(t).ExpectNil(err)
227235
test.S(t).ExpectEquals(parser.explicitSchema, "")
228236
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
237+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
229238
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
230239
}
231240
{
@@ -235,6 +244,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
235244
test.S(t).ExpectNil(err)
236245
test.S(t).ExpectEquals(parser.explicitSchema, "scm with spaces")
237246
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
247+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
238248
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
239249
}
240250
{
@@ -244,6 +254,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
244254
test.S(t).ExpectNil(err)
245255
test.S(t).ExpectEquals(parser.explicitSchema, "scm")
246256
test.S(t).ExpectEquals(parser.explicitTable, "tbl with spaces")
257+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
247258
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
248259
}
249260
{
@@ -253,6 +264,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
253264
test.S(t).ExpectNil(err)
254265
test.S(t).ExpectEquals(parser.explicitSchema, "scm")
255266
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
267+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
256268
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
257269
}
258270
{
@@ -262,6 +274,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
262274
test.S(t).ExpectNil(err)
263275
test.S(t).ExpectEquals(parser.explicitSchema, "scm")
264276
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
277+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
265278
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
266279
}
267280
{
@@ -271,6 +284,17 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
271284
test.S(t).ExpectNil(err)
272285
test.S(t).ExpectEquals(parser.explicitSchema, "scm")
273286
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
287+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b")
274288
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b"}))
275289
}
290+
{
291+
parser := NewAlterTableParser()
292+
statement := "alter table scm.tbl drop column b, add index idx(i)"
293+
err := parser.ParseAlterStatement(statement)
294+
test.S(t).ExpectNil(err)
295+
test.S(t).ExpectEquals(parser.explicitSchema, "scm")
296+
test.S(t).ExpectEquals(parser.explicitTable, "tbl")
297+
test.S(t).ExpectEquals(parser.alterStatementOptions, "drop column b, add index idx(i)")
298+
test.S(t).ExpectTrue(reflect.DeepEqual(parser.alterTokens, []string{"drop column b", "add index idx(i)"}))
299+
}
276300
}

0 commit comments

Comments
 (0)