@@ -5,14 +5,13 @@ import (
55 "os"
66 "testing"
77
8- "github.com/golang-migrate/migrate/v4"
9-
10- dt "github.com/golang-migrate/migrate/v4/database/testing"
11- _ "github.com/golang-migrate/migrate/v4/source/file"
12-
138 "cloud.google.com/go/spanner/spannertest"
149 "github.com/stretchr/testify/assert"
1510 "github.com/stretchr/testify/require"
11+
12+ "github.com/golang-migrate/migrate/v4"
13+ dt "github.com/golang-migrate/migrate/v4/database/testing"
14+ _ "github.com/golang-migrate/migrate/v4/source/file"
1615)
1716
1817// withSpannerEmulator is not thread-safe and cannot be used with parallel tests since it sets the emulator
@@ -75,75 +74,75 @@ func TestCleanStatements(t *testing.T) {
7574 {
7675 name : "single statement, single line, no semicolon, no comment" ,
7776 multiStatement : "CREATE TABLE table_name (id STRING(255) NOT NULL) PRIMARY KEY (id)" ,
78- expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL, \n ) PRIMARY KEY(id)" },
77+ expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL\n ) PRIMARY KEY (id)" },
7978 },
8079 {
8180 name : "single statement, multi line, no semicolon, no comment" ,
8281 multiStatement : `CREATE TABLE table_name (
83- id STRING(255) NOT NULL,
82+ id STRING(255) NOT NULL
8483 ) PRIMARY KEY (id)` ,
85- expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL, \n ) PRIMARY KEY(id)" },
84+ expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL\n ) PRIMARY KEY (id)" },
8685 },
8786 {
8887 name : "single statement, single line, with semicolon, no comment" ,
8988 multiStatement : "CREATE TABLE table_name (id STRING(255) NOT NULL) PRIMARY KEY (id);" ,
90- expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL, \n ) PRIMARY KEY(id)" },
89+ expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL\n ) PRIMARY KEY (id)" },
9190 },
9291 {
9392 name : "single statement, multi line, with semicolon, no comment" ,
9493 multiStatement : `CREATE TABLE table_name (
95- id STRING(255) NOT NULL,
94+ id STRING(255) NOT NULL
9695 ) PRIMARY KEY (id);` ,
97- expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL, \n ) PRIMARY KEY(id)" },
96+ expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL\n ) PRIMARY KEY (id)" },
9897 },
9998 {
10099 name : "multi statement, with trailing semicolon. no comment" ,
101100 // From https://github.com/mattes/migrate/pull/281
102101 multiStatement : `CREATE TABLE table_name (
103- id STRING(255) NOT NULL,
104- ) PRIMARY KEY(id);
102+ id STRING(255) NOT NULL
103+ ) PRIMARY KEY (id);
105104
106105 CREATE INDEX table_name_id_idx ON table_name (id);` ,
107106 expected : []string {`CREATE TABLE table_name (
108- id STRING(255) NOT NULL,
109- ) PRIMARY KEY(id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
107+ id STRING(255) NOT NULL
108+ ) PRIMARY KEY (id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
110109 },
111110 {
112111 name : "multi statement, no trailing semicolon, no comment" ,
113112 // From https://github.com/mattes/migrate/pull/281
114113 multiStatement : `CREATE TABLE table_name (
115- id STRING(255) NOT NULL,
116- ) PRIMARY KEY(id);
114+ id STRING(255) NOT NULL
115+ ) PRIMARY KEY (id);
117116
118117 CREATE INDEX table_name_id_idx ON table_name (id)` ,
119118 expected : []string {`CREATE TABLE table_name (
120- id STRING(255) NOT NULL,
121- ) PRIMARY KEY(id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
119+ id STRING(255) NOT NULL
120+ ) PRIMARY KEY (id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
122121 },
123122 {
124123 name : "multi statement, no trailing semicolon, standalone comment" ,
125124 // From https://github.com/mattes/migrate/pull/281
126125 multiStatement : `CREATE TABLE table_name (
127126 -- standalone comment
128- id STRING(255) NOT NULL,
129- ) PRIMARY KEY(id);
127+ id STRING(255) NOT NULL
128+ ) PRIMARY KEY (id);
130129
131130 CREATE INDEX table_name_id_idx ON table_name (id)` ,
132131 expected : []string {`CREATE TABLE table_name (
133- id STRING(255) NOT NULL,
134- ) PRIMARY KEY(id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
132+ id STRING(255) NOT NULL
133+ ) PRIMARY KEY (id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
135134 },
136135 {
137136 name : "multi statement, no trailing semicolon, inline comment" ,
138137 // From https://github.com/mattes/migrate/pull/281
139138 multiStatement : `CREATE TABLE table_name (
140139 id STRING(255) NOT NULL, -- inline comment
141- ) PRIMARY KEY(id);
140+ ) PRIMARY KEY (id);
142141
143142 CREATE INDEX table_name_id_idx ON table_name (id)` ,
144143 expected : []string {`CREATE TABLE table_name (
145- id STRING(255) NOT NULL,
146- ) PRIMARY KEY(id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
144+ id STRING(255) NOT NULL
145+ ) PRIMARY KEY (id)` , "CREATE INDEX table_name_id_idx ON table_name(id)" },
147146 },
148147 {
149148 name : "alter table with SET OPTIONS" ,
@@ -155,9 +154,9 @@ func TestCleanStatements(t *testing.T) {
155154 name : "column with NUMERIC type" ,
156155 multiStatement : `CREATE TABLE table_name (
157156 id STRING(255) NOT NULL,
158- sum NUMERIC,
157+ sum NUMERIC
159158 ) PRIMARY KEY (id)` ,
160- expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL,\n sum NUMERIC, \n ) PRIMARY KEY(id)" },
159+ expected : []string {"CREATE TABLE table_name (\n id STRING(255) NOT NULL,\n sum NUMERIC\n ) PRIMARY KEY (id)" },
161160 },
162161 }
163162
0 commit comments