22import * as assert from 'assert' ;
33import * as assertRejects from 'assert-rejects' ;
44import 'mocha' ; // tslint:disable-line:no-import-side-effect
5- import factory from '../factory' ;
65import DuplicateKeyError from '../utils/errors/DuplicateKeyError' ;
76import FailingMigrationError from '../utils/errors/FailingMigrationError' ;
87import MissingMigrationError from '../utils/errors/MissingMigrationError' ;
98import assertLocked from '../utils/tests/assertLocked' ;
109import createMigrationProcess from '../utils/tests/createMigrationProcess' ;
1110import createTestDownMigration from '../utils/tests/createTestDownMigration' ;
1211import TestFactory from '../utils/tests/TestFactory' ;
13- import Migration from '../utils/types/Migration' ;
1412
15- const testRollback : TestFactory = ( repoFactory ) => {
13+ const testRollback : TestFactory = ( createService ) => {
1614 const successfulMigration = createTestDownMigration ( undefined , 'successfulMigration' ) ;
1715 const failingMigration = createTestDownMigration ( ( ) => {
1816 throw new Error ( ) ;
1917 } , 'failingMigration' ) ;
2018 const unskippableKey = 'unskippableMigration' ;
2119 const unskippableMigration = createTestDownMigration ( undefined , unskippableKey ) ;
2220
23- const createService = ( migrations : Migration [ ] = [ ] ) => {
24- const log = ( ) => null ;
25- return factory ( { log, repo : repoFactory ( migrations ) } ) ;
26- } ;
27-
2821 describe ( 'rollback' , ( ) => {
2922 it ( 'should not error when there are no migrations' , async ( ) => {
30- const service = createService ( ) ;
23+ const service = createService ( [ ] ) ;
3124 await service . rollback ( ) ;
3225 } ) ;
3326
@@ -40,7 +33,7 @@ const testRollback: TestFactory = (repoFactory) => {
4033
4134 it ( 'should error when a processed migration is missing' , async ( ) => {
4235 await createService ( [ successfulMigration ] ) . migrate ( ) ;
43- const promise = createService ( ) . rollback ( ) ;
36+ const promise = createService ( [ ] ) . rollback ( ) ;
4437 await assertRejects ( promise , MissingMigrationError ) ;
4538 } ) ;
4639
@@ -98,7 +91,7 @@ const testRollback: TestFactory = (repoFactory) => {
9891 } ) ;
9992
10093 it ( 'should error when migrations are locked' , async ( ) => {
101- const service = createService ( ) ;
94+ const service = createService ( [ ] ) ;
10295 await assertLocked ( [ service . rollback ( ) , service . rollback ( ) ] ) ;
10396 } ) ;
10497 } ) ;
0 commit comments