2
2
import * as assert from 'assert' ;
3
3
import * as assertRejects from 'assert-rejects' ;
4
4
import 'mocha' ; // tslint:disable-line:no-import-side-effect
5
- import factory from '../factory' ;
6
5
import DuplicateKeyError from '../utils/errors/DuplicateKeyError' ;
7
6
import FailingMigrationError from '../utils/errors/FailingMigrationError' ;
8
7
import MissingMigrationError from '../utils/errors/MissingMigrationError' ;
9
8
import assertLocked from '../utils/tests/assertLocked' ;
10
9
import createMigrationProcess from '../utils/tests/createMigrationProcess' ;
11
10
import createTestDownMigration from '../utils/tests/createTestDownMigration' ;
12
11
import TestFactory from '../utils/tests/TestFactory' ;
13
- import Migration from '../utils/types/Migration' ;
14
12
15
- const testRollback : TestFactory = ( repoFactory ) => {
13
+ const testRollback : TestFactory = ( createService ) => {
16
14
const successfulMigration = createTestDownMigration ( undefined , 'successfulMigration' ) ;
17
15
const failingMigration = createTestDownMigration ( ( ) => {
18
16
throw new Error ( ) ;
19
17
} , 'failingMigration' ) ;
20
18
const unskippableKey = 'unskippableMigration' ;
21
19
const unskippableMigration = createTestDownMigration ( undefined , unskippableKey ) ;
22
20
23
- const createService = ( migrations : Migration [ ] = [ ] ) => {
24
- const log = ( ) => null ;
25
- return factory ( { log, repo : repoFactory ( migrations ) } ) ;
26
- } ;
27
-
28
21
describe ( 'rollback' , ( ) => {
29
22
it ( 'should not error when there are no migrations' , async ( ) => {
30
- const service = createService ( ) ;
23
+ const service = createService ( [ ] ) ;
31
24
await service . rollback ( ) ;
32
25
} ) ;
33
26
@@ -40,7 +33,7 @@ const testRollback: TestFactory = (repoFactory) => {
40
33
41
34
it ( 'should error when a processed migration is missing' , async ( ) => {
42
35
await createService ( [ successfulMigration ] ) . migrate ( ) ;
43
- const promise = createService ( ) . rollback ( ) ;
36
+ const promise = createService ( [ ] ) . rollback ( ) ;
44
37
await assertRejects ( promise , MissingMigrationError ) ;
45
38
} ) ;
46
39
@@ -98,7 +91,7 @@ const testRollback: TestFactory = (repoFactory) => {
98
91
} ) ;
99
92
100
93
it ( 'should error when migrations are locked' , async ( ) => {
101
- const service = createService ( ) ;
94
+ const service = createService ( [ ] ) ;
102
95
await assertLocked ( [ service . rollback ( ) , service . rollback ( ) ] ) ;
103
96
} ) ;
104
97
} ) ;
0 commit comments