File tree 1 file changed +32
-0
lines changed 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ var Code = require ( 'code' ) ;
2
+ var Lab = require ( 'lab' ) ;
3
+ var proxyquire = require ( 'proxyquire' ) . noPreserveCache ( ) ;
4
+ var lab = ( exports . lab = Lab . script ( ) ) ;
5
+
6
+ lab . experiment ( 'migrators' , function ( ) {
7
+ lab . experiment ( 'check' , function ( ) {
8
+ lab . test ( 'should return the migrations to be run' , function ( done ) {
9
+ var completedMigration = {
10
+ name : '20180330020329-thisMigrationIsCompleted'
11
+ } ;
12
+ var uncompletedMigration = {
13
+ name : '20180330020330-thisMigrationIsNotCompleted'
14
+ } ;
15
+ var Migrator = proxyquire ( '../lib/migrator.js' , {
16
+ './migration' : {
17
+ loadFromFilesystem : ( migrationsDir , internals , cb ) => {
18
+ return cb ( null , [ completedMigration , uncompletedMigration ] ) ;
19
+ } ,
20
+ loadFromDatabase : ( migrationsDir , driver , internals , cb ) => {
21
+ return cb ( null , [ completedMigration ] ) ;
22
+ }
23
+ }
24
+ } ) ;
25
+ Migrator . prototype . check ( null , function ( err , res ) {
26
+ Code . expect ( res . length ) . to . equal ( 1 ) ;
27
+ Code . expect ( res [ 0 ] . name ) . to . equal ( uncompletedMigration . name ) ;
28
+ done ( err , res ) ;
29
+ } ) ;
30
+ } ) ;
31
+ } ) ;
32
+ } ) ;
You can’t perform that action at this time.
0 commit comments