@@ -198,39 +198,6 @@ describe('CLI: make', () => {
198198 expect ( migrationFile ) . to . equal ( interpolate ( fileOutput , { table : 'demo_users' } ) ) ;
199199 } ) ;
200200
201- it ( 'should create a migration file with template when name matches filename convention for typescript.' , async ( ) => {
202- // Write sync-db.yml file.
203- const cwd = await mkdtemp ( ) ;
204- const migrationPath = path . join ( cwd , 'src/migration' ) ;
205- await mkdir ( migrationPath , { recursive : true } ) ;
206- await write (
207- path . join ( cwd , 'sync-db.yml' ) ,
208- yaml . stringify ( {
209- migration : {
210- directory : 'migration' ,
211- sourceType : 'typescript'
212- }
213- } as Configuration )
214- ) ;
215-
216- const { stdout } = await runCli ( [ 'make' , 'create_demo_users_table' ] , { cwd } ) ;
217-
218- // Check the output.
219- expect ( stdout ) . to . match ( / C r e a t e d .+ \d { 13 } _ c r e a t e _ d e m o _ u s e r s _ t a b l e \. t s / ) ;
220-
221- // Check files are created.
222- const files = await glob ( migrationPath ) ;
223-
224- expect ( files . length ) . to . equal ( 1 ) ;
225-
226- const migrationFile = await read (
227- path . join ( migrationPath , queryByPattern ( files , / \d { 13 } _ c r e a t e _ d e m o _ u s e r s _ t a b l e \. t s / ) )
228- ) ;
229- const fileOutput = await read ( path . join ( MIGRATION_TEMPLATE_PATH , 'create_ts.stub' ) ) ;
230-
231- expect ( migrationFile ) . to . equal ( interpolate ( fileOutput , { table : 'demo_users' } ) ) ;
232- } ) ;
233-
234201 it ( 'should create a migration file with custom template for typescript.' , async ( ) => {
235202 // Write sync-db.yml file.
236203 const cwd = await mkdtemp ( ) ;
@@ -334,4 +301,55 @@ describe('CLI: make', () => {
334301 expect ( upFile ) . to . equal ( interpolate ( upSQL , { table : 'settings' } ) ) ;
335302 expect ( downFile ) . to . equal ( interpolate ( downSQL , { table : 'settings' } ) ) ;
336303 } ) ;
304+
305+ it ( 'should make migration based on custom configurations with --config flag.' , async ( ) => {
306+ // Write sync-db.yml file.
307+ const cwd = await mkdtemp ( ) ;
308+
309+ const migrationPath = path . join ( cwd , 'src/migration' ) ;
310+ await mkdir ( migrationPath , { recursive : true } ) ;
311+
312+ const migrationPath1 = path . join ( cwd , 'src/migration1' ) ;
313+ await mkdir ( migrationPath1 , { recursive : true } ) ;
314+
315+ await write (
316+ path . join ( cwd , 'sync-db.yml' ) ,
317+ yaml . stringify ( {
318+ migration : {
319+ directory : 'migration'
320+ }
321+ } as Configuration )
322+ ) ;
323+
324+ await write (
325+ path . join ( cwd , 'sync-db-test.yml' ) ,
326+ yaml . stringify ( {
327+ migration : {
328+ directory : 'migration1' ,
329+ sourceType : 'typescript'
330+ }
331+ } as Configuration )
332+ ) ;
333+
334+ const { stdout } = await runCli ( [ 'make' , 'settings' ] , { cwd } ) ;
335+
336+ // Check the output.
337+ expect ( stdout ) . to . match ( / C r e a t e d .+ \d { 13 } _ s e t t i n g s \. u p \. s q l / ) ;
338+ expect ( stdout ) . to . match ( / C r e a t e d .+ \d { 13 } _ s e t t i n g s \. d o w n \. s q l / ) ;
339+
340+ // Check files are created.
341+ const files = await glob ( migrationPath ) ;
342+
343+ expect ( files . length ) . to . equal ( 2 ) ;
344+
345+ const { stdout : stdout1 } = await runCli ( [ 'make' , 'settings' , '--config=sync-db-test.yml' ] , { cwd } ) ;
346+
347+ // Check the output.
348+ expect ( stdout1 ) . to . match ( / C r e a t e d .+ \d { 13 } _ s e t t i n g s \. t s / ) ;
349+
350+ // Check files are created.
351+ const files1 = await glob ( migrationPath1 ) ;
352+
353+ expect ( files1 . length ) . to . equal ( 1 ) ;
354+ } ) ;
337355} ) ;
0 commit comments