@@ -51,7 +51,7 @@ impl<'conn> DatabaseVersionChecker<'conn> {
51
51
}
52
52
53
53
/// Apply migrations
54
- pub async fn apply ( & self ) -> StdResult < ( ) > {
54
+ pub fn apply ( & self ) -> StdResult < ( ) > {
55
55
debug ! ( & self . logger, "check database version" , ) ;
56
56
let provider = DatabaseVersionProvider :: new ( self . connection ) ;
57
57
provider
@@ -179,7 +179,7 @@ mod tests {
179
179
180
180
use super :: * ;
181
181
182
- async fn check_database_version ( connection : & SqliteConnection , db_version : DbVersion ) {
182
+ fn check_database_version ( connection : & SqliteConnection , db_version : DbVersion ) {
183
183
let provider = DatabaseVersionProvider :: new ( connection) ;
184
184
let version = provider
185
185
. get_application_version ( & ApplicationNodeType :: Aggregator )
@@ -199,7 +199,7 @@ mod tests {
199
199
Ok ( ( filepath, connection) )
200
200
}
201
201
202
- async fn get_table_whatever_column_count ( connection : & SqliteConnection ) -> i64 {
202
+ fn get_table_whatever_column_count ( connection : & SqliteConnection ) -> i64 {
203
203
let sql = "select count(*) as column_count from pragma_table_info('whatever');" ;
204
204
let column_count = connection
205
205
. prepare ( sql)
@@ -213,8 +213,8 @@ mod tests {
213
213
column_count
214
214
}
215
215
216
- #[ tokio :: test]
217
- async fn test_upgrade_with_migration ( ) {
216
+ #[ test]
217
+ fn test_upgrade_with_migration ( ) {
218
218
let ( _filepath, connection) =
219
219
create_sqlite_file ( "test_upgrade_with_migration.sqlite3" ) . unwrap ( ) ;
220
220
let mut db_checker = DatabaseVersionChecker :: new (
@@ -223,35 +223,35 @@ mod tests {
223
223
& connection,
224
224
) ;
225
225
226
- db_checker. apply ( ) . await . unwrap ( ) ;
227
- assert_eq ! ( 0 , get_table_whatever_column_count( & connection) . await ) ;
226
+ db_checker. apply ( ) . unwrap ( ) ;
227
+ assert_eq ! ( 0 , get_table_whatever_column_count( & connection) ) ;
228
228
229
- db_checker. apply ( ) . await . unwrap ( ) ;
230
- assert_eq ! ( 0 , get_table_whatever_column_count( & connection) . await ) ;
229
+ db_checker. apply ( ) . unwrap ( ) ;
230
+ assert_eq ! ( 0 , get_table_whatever_column_count( & connection) ) ;
231
231
232
232
let alterations = "create table whatever (thing_id integer); insert into whatever (thing_id) values (1), (2), (3), (4);" ;
233
233
let migration = SqlMigration {
234
234
version : 1 ,
235
235
alterations : alterations. to_string ( ) ,
236
236
} ;
237
237
db_checker. add_migration ( migration) ;
238
- db_checker. apply ( ) . await . unwrap ( ) ;
239
- assert_eq ! ( 1 , get_table_whatever_column_count( & connection) . await ) ;
240
- check_database_version ( & connection, 1 ) . await ;
238
+ db_checker. apply ( ) . unwrap ( ) ;
239
+ assert_eq ! ( 1 , get_table_whatever_column_count( & connection) ) ;
240
+ check_database_version ( & connection, 1 ) ;
241
241
242
- db_checker. apply ( ) . await . unwrap ( ) ;
243
- assert_eq ! ( 1 , get_table_whatever_column_count( & connection) . await ) ;
244
- check_database_version ( & connection, 1 ) . await ;
242
+ db_checker. apply ( ) . unwrap ( ) ;
243
+ assert_eq ! ( 1 , get_table_whatever_column_count( & connection) ) ;
244
+ check_database_version ( & connection, 1 ) ;
245
245
246
246
let alterations = "alter table whatever add column thing_content text; update whatever set thing_content = 'some content'" ;
247
247
let migration = SqlMigration {
248
248
version : 2 ,
249
249
alterations : alterations. to_string ( ) ,
250
250
} ;
251
251
db_checker. add_migration ( migration) ;
252
- db_checker. apply ( ) . await . unwrap ( ) ;
253
- assert_eq ! ( 2 , get_table_whatever_column_count( & connection) . await ) ;
254
- check_database_version ( & connection, 2 ) . await ;
252
+ db_checker. apply ( ) . unwrap ( ) ;
253
+ assert_eq ! ( 2 , get_table_whatever_column_count( & connection) ) ;
254
+ check_database_version ( & connection, 2 ) ;
255
255
256
256
// in the test below both migrations are declared in reversed order to
257
257
// ensure they are played in the right order. The last one depends on
@@ -268,13 +268,13 @@ mod tests {
268
268
alterations : alterations. to_string ( ) ,
269
269
} ;
270
270
db_checker. add_migration ( migration) ;
271
- db_checker. apply ( ) . await . unwrap ( ) ;
272
- assert_eq ! ( 4 , get_table_whatever_column_count( & connection) . await ) ;
273
- check_database_version ( & connection, 4 ) . await ;
271
+ db_checker. apply ( ) . unwrap ( ) ;
272
+ assert_eq ! ( 4 , get_table_whatever_column_count( & connection) ) ;
273
+ check_database_version ( & connection, 4 ) ;
274
274
}
275
275
276
- #[ tokio :: test]
277
- async fn starting_with_migration ( ) {
276
+ #[ test]
277
+ fn starting_with_migration ( ) {
278
278
let ( _filepath, connection) = create_sqlite_file ( "starting_with_migration" ) . unwrap ( ) ;
279
279
let mut db_checker = DatabaseVersionChecker :: new (
280
280
slog_scope:: logger ( ) ,
@@ -288,16 +288,16 @@ mod tests {
288
288
alterations : alterations. to_string ( ) ,
289
289
} ;
290
290
db_checker. add_migration ( migration) ;
291
- db_checker. apply ( ) . await . unwrap ( ) ;
292
- assert_eq ! ( 1 , get_table_whatever_column_count( & connection) . await ) ;
293
- check_database_version ( & connection, 1 ) . await ;
291
+ db_checker. apply ( ) . unwrap ( ) ;
292
+ assert_eq ! ( 1 , get_table_whatever_column_count( & connection) ) ;
293
+ check_database_version ( & connection, 1 ) ;
294
294
}
295
295
296
- #[ tokio :: test]
296
+ #[ test]
297
297
/// This test case ensure that when multiple migrations are played and one fails:
298
298
/// * previous migrations are ok and the database version is updated
299
299
/// * further migrations are not played.
300
- async fn test_failing_migration ( ) {
300
+ fn test_failing_migration ( ) {
301
301
let ( _filepath, connection) = create_sqlite_file ( "test_failing_migration" ) . unwrap ( ) ;
302
302
let mut db_checker = DatabaseVersionChecker :: new (
303
303
slog_scope:: logger ( ) ,
@@ -323,12 +323,12 @@ mod tests {
323
323
alterations : alterations. to_string ( ) ,
324
324
} ;
325
325
db_checker. add_migration ( migration) ;
326
- db_checker. apply ( ) . await . unwrap_err ( ) ;
327
- check_database_version ( & connection, 1 ) . await ;
326
+ db_checker. apply ( ) . unwrap_err ( ) ;
327
+ check_database_version ( & connection, 1 ) ;
328
328
}
329
329
330
- #[ tokio :: test]
331
- async fn test_fail_downgrading ( ) {
330
+ #[ test]
331
+ fn test_fail_downgrading ( ) {
332
332
let ( _filepath, connection) = create_sqlite_file ( "test_fail_downgrading" ) . unwrap ( ) ;
333
333
let mut db_checker = DatabaseVersionChecker :: new (
334
334
slog_scope:: logger ( ) ,
@@ -341,8 +341,8 @@ mod tests {
341
341
alterations : alterations. to_string ( ) ,
342
342
} ;
343
343
db_checker. add_migration ( migration) ;
344
- db_checker. apply ( ) . await . unwrap ( ) ;
345
- check_database_version ( & connection, 1 ) . await ;
344
+ db_checker. apply ( ) . unwrap ( ) ;
345
+ check_database_version ( & connection, 1 ) ;
346
346
347
347
// re instantiate a new checker with no migration registered (version 0).
348
348
let db_checker = DatabaseVersionChecker :: new (
@@ -351,9 +351,9 @@ mod tests {
351
351
& connection,
352
352
) ;
353
353
assert ! (
354
- db_checker. apply( ) . await . is_err( ) ,
354
+ db_checker. apply( ) . is_err( ) ,
355
355
"using an old version with an up to date database should fail"
356
356
) ;
357
- check_database_version ( & connection, 1 ) . await ;
357
+ check_database_version ( & connection, 1 ) ;
358
358
}
359
359
}
0 commit comments