@@ -38,10 +38,10 @@ func TestMigrate(t *testing.T) {
3838 err = m .Migrate ()
3939 assert .Nil (t , err )
4040
41- tableMustExist (t , db , "migrations" )
42- tableMustExist (t , db , "test1" )
43- tableMustExist (t , db , "test2" )
44- tableMustNotExist (t , db , "test3" )
41+ tableMustExistSqlite (t , db , "migrations" )
42+ tableMustExistSqlite (t , db , "test1" )
43+ tableMustExistSqlite (t , db , "test2" )
44+ tableMustNotExistSqlite (t , db , "test3" )
4545
4646 os .Remove (testDbPath )
4747 })
@@ -74,16 +74,16 @@ func TestMigrate(t *testing.T) {
7474 err = m .Migrate ()
7575 assert .Nil (t , err )
7676
77- tableMustExist (t , db , "migrations" )
78- tableMustExist (t , db , "test1" )
79- tableMustExist (t , db , "test2" )
77+ tableMustExistSqlite (t , db , "migrations" )
78+ tableMustExistSqlite (t , db , "test1" )
79+ tableMustExistSqlite (t , db , "test2" )
8080
8181 err = m .Migrate ()
8282 assert .Nil (t , err )
8383
84- tableMustExist (t , db , "migrations" )
85- tableMustExist (t , db , "test1" )
86- tableMustExist (t , db , "test2" )
84+ tableMustExistSqlite (t , db , "migrations" )
85+ tableMustExistSqlite (t , db , "test1" )
86+ tableMustExistSqlite (t , db , "test2" )
8787
8888 os .Remove (testDbPath )
8989 })
@@ -116,10 +116,10 @@ func TestMigrate(t *testing.T) {
116116 err = m .Migrate ()
117117 assert .Nil (t , err )
118118
119- tableMustExist (t , db , "migrations" )
120- tableMustExist (t , db , "test1" )
121- tableMustExist (t , db , "test2" )
122- tableMustNotExist (t , db , "test3" )
119+ tableMustExistSqlite (t , db , "migrations" )
120+ tableMustExistSqlite (t , db , "test1" )
121+ tableMustExistSqlite (t , db , "test2" )
122+ tableMustNotExistSqlite (t , db , "test3" )
123123
124124 m .config .Migrations = append (m .config .Migrations , Migration {
125125 Id : 3 ,
@@ -130,10 +130,10 @@ func TestMigrate(t *testing.T) {
130130 err = m .Migrate ()
131131 assert .Nil (t , err )
132132
133- tableMustExist (t , db , "migrations" )
134- tableMustExist (t , db , "test1" )
135- tableMustExist (t , db , "test2" )
136- tableMustExist (t , db , "test3" )
133+ tableMustExistSqlite (t , db , "migrations" )
134+ tableMustExistSqlite (t , db , "test1" )
135+ tableMustExistSqlite (t , db , "test2" )
136+ tableMustExistSqlite (t , db , "test3" )
137137
138138 os .Remove (testDbPath )
139139 })
@@ -171,20 +171,20 @@ func TestMigrate(t *testing.T) {
171171 err = m .Migrate ()
172172 assert .Nil (t , err )
173173
174- tableMustExist (t , db , "migrations" )
175- tableMustExist (t , db , "test1" )
176- tableMustExist (t , db , "test2" )
177- tableMustExist (t , db , "test3" )
174+ tableMustExistSqlite (t , db , "migrations" )
175+ tableMustExistSqlite (t , db , "test1" )
176+ tableMustExistSqlite (t , db , "test2" )
177+ tableMustExistSqlite (t , db , "test3" )
178178
179179 m .config .Migrations = m .config .Migrations [:2 ]
180180
181181 err = m .Migrate ()
182182 assert .Nil (t , err )
183183
184- tableMustExist (t , db , "migrations" )
185- tableMustExist (t , db , "test1" )
186- tableMustExist (t , db , "test2" )
187- tableMustNotExist (t , db , "test3" )
184+ tableMustExistSqlite (t , db , "migrations" )
185+ tableMustExistSqlite (t , db , "test1" )
186+ tableMustExistSqlite (t , db , "test2" )
187+ tableMustNotExistSqlite (t , db , "test3" )
188188
189189 os .Remove (testDbPath )
190190 })
@@ -222,36 +222,36 @@ func TestMigrate(t *testing.T) {
222222 err = m .Migrate ()
223223 assert .Nil (t , err )
224224
225- tableMustExist (t , db , "migrations" )
226- tableMustExist (t , db , "test1" )
227- tableMustExist (t , db , "test2" )
228- tableMustExist (t , db , "test3" )
229- tableMustNotExist (t , db , "test4" )
225+ tableMustExistSqlite (t , db , "migrations" )
226+ tableMustExistSqlite (t , db , "test1" )
227+ tableMustExistSqlite (t , db , "test2" )
228+ tableMustExistSqlite (t , db , "test3" )
229+ tableMustNotExistSqlite (t , db , "test4" )
230230
231231 m .config .Migrations [1 ].Up = "CREATE TABLE test4 (id INTEGER PRIMARY KEY, name TEXT, age INTEGER);"
232232 m .config .Migrations [1 ].Down = "DROP TABLE test4;"
233233
234234 err = m .Migrate ()
235235 assert .Nil (t , err )
236236
237- tableMustExist (t , db , "migrations" )
238- tableMustExist (t , db , "test1" )
239- tableMustNotExist (t , db , "test2" )
240- tableMustExist (t , db , "test3" )
241- tableMustExist (t , db , "test4" )
237+ tableMustExistSqlite (t , db , "migrations" )
238+ tableMustExistSqlite (t , db , "test1" )
239+ tableMustNotExistSqlite (t , db , "test2" )
240+ tableMustExistSqlite (t , db , "test3" )
241+ tableMustExistSqlite (t , db , "test4" )
242242
243243 m .config .Migrations [0 ].Up = "CREATE TABLE test5 (id INTEGER PRIMARY KEY, name TEXT);"
244244 m .config .Migrations [0 ].Down = "DROP TABLE test5;"
245245
246246 err = m .Migrate ()
247247 assert .Nil (t , err )
248248
249- tableMustExist (t , db , "migrations" )
250- tableMustNotExist (t , db , "test1" )
251- tableMustNotExist (t , db , "test2" )
252- tableMustExist (t , db , "test3" )
253- tableMustExist (t , db , "test4" )
254- tableMustExist (t , db , "test5" )
249+ tableMustExistSqlite (t , db , "migrations" )
250+ tableMustNotExistSqlite (t , db , "test1" )
251+ tableMustNotExistSqlite (t , db , "test2" )
252+ tableMustExistSqlite (t , db , "test3" )
253+ tableMustExistSqlite (t , db , "test4" )
254+ tableMustExistSqlite (t , db , "test5" )
255255
256256 os .Remove (testDbPath )
257257 })
@@ -271,37 +271,37 @@ func TestMigrate(t *testing.T) {
271271 err = m .Migrate ()
272272 assert .Nil (t , err )
273273
274- tableMustExist (t , db , "migrations" )
275- tableMustExist (t , db , "test_table_1" )
276- tableMustExist (t , db , "test_table_2" )
277- tableMustExist (t , db , "test_table_3" )
278- tableMustNotExist (t , db , "test_table_4" )
274+ tableMustExistSqlite (t , db , "migrations" )
275+ tableMustExistSqlite (t , db , "test_table_1" )
276+ tableMustExistSqlite (t , db , "test_table_2" )
277+ tableMustExistSqlite (t , db , "test_table_3" )
278+ tableMustNotExistSqlite (t , db , "test_table_4" )
279279
280280 m .config .Migrations [2 ].Up = "CREATE TABLE test_table_5 (id INTEGER PRIMARY KEY, name TEXT);"
281281 m .config .Migrations [2 ].Down = "DROP TABLE test_table_5;"
282282 err = m .Migrate ()
283283 assert .Nil (t , err )
284284
285- tableMustExist (t , db , "migrations" )
286- tableMustExist (t , db , "test_table_1" )
287- tableMustExist (t , db , "test_table_2" )
288- tableMustNotExist (t , db , "test_table_3" )
289- tableMustNotExist (t , db , "test_table_4" )
290- tableMustExist (t , db , "test_table_5" )
285+ tableMustExistSqlite (t , db , "migrations" )
286+ tableMustExistSqlite (t , db , "test_table_1" )
287+ tableMustExistSqlite (t , db , "test_table_2" )
288+ tableMustNotExistSqlite (t , db , "test_table_3" )
289+ tableMustNotExistSqlite (t , db , "test_table_4" )
290+ tableMustExistSqlite (t , db , "test_table_5" )
291291
292292 os .Remove (testDbPath )
293293 })
294294}
295295
296- func tableMustExist (t * testing.T , db * sql.DB , tableName string ) {
297- rows , err := db .Query ("SELECT name FROM sqlite_master WHERE type='table' AND name=? ;" , tableName )
296+ func tableMustExistSqlite (t * testing.T , db * sql.DB , tableName string ) {
297+ rows , err := db .Query ("SELECT name FROM sqlite_master WHERE type='table' AND name=$1 ;" , tableName )
298298 assert .Nil (t , err )
299299 defer rows .Close ()
300300 assert .True (t , rows .Next (), "table %s must exist" , tableName )
301301}
302302
303- func tableMustNotExist (t * testing.T , db * sql.DB , tableName string ) {
304- rows , err := db .Query ("SELECT name FROM sqlite_master WHERE type='table' AND name=? ;" , tableName )
303+ func tableMustNotExistSqlite (t * testing.T , db * sql.DB , tableName string ) {
304+ rows , err := db .Query ("SELECT name FROM sqlite_master WHERE type='table' AND name=$1 ;" , tableName )
305305 assert .Nil (t , err )
306306 defer rows .Close ()
307307 assert .False (t , rows .Next (), "table %s must not exist" , tableName )
0 commit comments