@@ -216,6 +216,61 @@ lab.experiment('create', function () {
216
216
} ) ;
217
217
}
218
218
) ;
219
+ lab . experiment (
220
+ 'with scoped migration' ,
221
+ function ( ) {
222
+ let exitCode ;
223
+ lab . experiment ( 'without a migration directory' , function ( ) {
224
+ let exitCode ;
225
+
226
+ lab . before ( function ( done ) {
227
+ wipeMigrations ( function ( err ) {
228
+ Code . expect ( err ) . to . be . null ( ) ;
229
+ const configOption = path . join ( '--sql-file' ) ;
230
+ const db = dbMigrate ( 'create' , 'test/first migration' , configOption ) ;
231
+ // db.stderr.on('data', data => console.log(data.toString()));
232
+ // db.stdout.on('data', data => console.log(data.toString()));
233
+
234
+ db . on ( 'exit' , function ( code ) {
235
+ exitCode = code ;
236
+ done ( ) ;
237
+ } ) ;
238
+ } ) ;
239
+ } ) ;
240
+
241
+ lab . test ( 'does not cause an error' , function ( done ) {
242
+ Code . expect ( exitCode ) . to . equal ( 0 ) ;
243
+ done ( ) ;
244
+ } ) ;
245
+
246
+ lab . test ( 'will create a new migration directory' , function ( done ) {
247
+ const stats = fs . statSync ( path . join ( __dirname , 'migrations/test' ) ) ;
248
+ Code . expect ( stats . isDirectory ( ) ) . to . be . true ( ) ;
249
+ done ( ) ;
250
+ } ) ;
251
+
252
+ lab . test ( 'will create a new migration' , function ( done ) {
253
+ const files = fs . readdirSync ( path . join ( __dirname , 'migrations/test' ) ) ;
254
+ Code . expect ( files . length ) . to . equal ( 2 ) ;
255
+ const file = files [ 0 ] ;
256
+ Code . expect ( file ) . to . match ( / f i r s t - m i g r a t i o n \. j s $ / ) ;
257
+ done ( ) ;
258
+ } ) ;
259
+ lab . test ( 'will create a new migration/test/sqls directory' , function ( done ) {
260
+ const stats = fs . statSync ( path . join ( __dirname , 'migrations/test/sqls' ) ) ;
261
+ Code . expect ( stats . isDirectory ( ) ) . to . be . true ( ) ;
262
+ done ( ) ;
263
+ } ) ;
264
+ lab . test ( 'will create a new migration sql up file' , function ( done ) {
265
+ const files = fs . readdirSync ( path . join ( __dirname , 'migrations/test/sqls' ) ) ;
266
+ Code . expect ( files . length ) . to . equal ( 2 ) ;
267
+ const file = files [ 1 ] ;
268
+ Code . expect ( file ) . to . match ( / f i r s t - m i g r a t i o n - u p \. s q l $ / ) ;
269
+ done ( ) ;
270
+ } ) ;
271
+ } ) ;
272
+ }
273
+ ) ;
219
274
220
275
lab . experiment (
221
276
'with coffee-file option set to true as a command parameter' ,
0 commit comments