@@ -3,7 +3,7 @@ const expect = require('chai').expect;
3
3
const sinon = require ( 'sinon' ) ;
4
4
const proxyquire = require ( 'proxyquire' ) . noCallThru ( ) ;
5
5
const configStub = require ( '../../utils/config-stub' ) ;
6
- const setupEnv = require ( '../../utils/env ' ) ;
6
+ const { setupTestFolder , cleanupTestFolders } = require ( '../../utils/test-folder ' ) ;
7
7
const Promise = require ( 'bluebird' ) ;
8
8
const path = require ( 'path' ) ;
9
9
const fs = require ( 'fs-extra' ) ;
@@ -13,6 +13,10 @@ const errors = require('../../../lib/errors');
13
13
const Instance = require ( '../../../lib/instance' ) ;
14
14
15
15
describe ( 'Unit: Commands > Update' , function ( ) {
16
+ after ( ( ) => {
17
+ cleanupTestFolders ( ) ;
18
+ } ) ;
19
+
16
20
it ( 'configureOptions adds setup & doctor options' , function ( ) {
17
21
const superStub = sinon . stub ( ) . returnsArg ( 1 ) ;
18
22
const doctorStub = sinon . stub ( ) . returnsArg ( 1 ) ;
@@ -339,7 +343,7 @@ describe('Unit: Commands > Update', function () {
339
343
'../tasks/yarn-install' : yarnInstallStub
340
344
} ) ;
341
345
const instance = new UpdateCommand ( { } , { } ) ;
342
- const env = setupEnv ( ) ;
346
+ const env = setupTestFolder ( ) ;
343
347
const ctx = {
344
348
installPath : path . join ( env . dir , 'versions/1.0.0' ) ,
345
349
version : '1.0.0'
@@ -349,7 +353,6 @@ describe('Unit: Commands > Update', function () {
349
353
return instance . downloadAndUpdate ( ctx , task ) . then ( ( ) => {
350
354
expect ( yarnInstallStub . calledOnce ) . to . be . true ;
351
355
expect ( task . title ) . to . equal ( 'Downloading and updating Ghost to v1.0.0' ) ;
352
- env . cleanup ( ) ;
353
356
} ) ;
354
357
} ) ;
355
358
@@ -363,7 +366,7 @@ describe('Unit: Commands > Update', function () {
363
366
dirs : [ 'versions/1.0.0' , 'versions/1.0.1' ] ,
364
367
links : [ [ 'versions/1.0.0' , 'current' ] ]
365
368
} ;
366
- const env = setupEnv ( envCfg ) ;
369
+ const env = setupTestFolder ( envCfg ) ;
367
370
const ctx = {
368
371
installPath : path . join ( env . dir , 'versions/1.0.1' ) ,
369
372
force : false
@@ -376,8 +379,6 @@ describe('Unit: Commands > Update', function () {
376
379
expect ( fs . existsSync ( ctx . installPath ) ) . to . be . true ;
377
380
expect ( yarnInstallStub . called ) . to . be . false ;
378
381
expect ( task . skip . calledOnce ) . to . be . true ;
379
-
380
- env . cleanup ( ) ;
381
382
} ) ;
382
383
} ) ;
383
384
@@ -391,7 +392,7 @@ describe('Unit: Commands > Update', function () {
391
392
dirs : [ 'versions/1.0.0' , 'versions/1.0.1' ] ,
392
393
links : [ [ 'versions/1.0.0' , 'current' ] ]
393
394
} ;
394
- const env = setupEnv ( envCfg ) ;
395
+ const env = setupTestFolder ( envCfg ) ;
395
396
const ctx = {
396
397
installPath : path . join ( env . dir , 'versions/1.0.1' ) ,
397
398
force : true
@@ -402,8 +403,6 @@ describe('Unit: Commands > Update', function () {
402
403
return instance . downloadAndUpdate ( ctx , { } ) . then ( ( ) => {
403
404
expect ( fs . existsSync ( ctx . installPath ) ) . to . be . false ;
404
405
expect ( yarnInstallStub . calledOnce ) . to . be . true ;
405
-
406
- env . cleanup ( ) ;
407
406
} ) ;
408
407
} ) ;
409
408
} ) ;
@@ -480,7 +479,7 @@ describe('Unit: Commands > Update', function () {
480
479
'versions/1.5.1' ,
481
480
'versions/1.5.2'
482
481
] ;
483
- const env = setupEnv ( { dirs : dirs } ) ;
482
+ const env = setupTestFolder ( { dirs : dirs } ) ;
484
483
const UpdateCommand = require ( modulePath ) ;
485
484
const instance = new UpdateCommand ( { } , { } ) ;
486
485
const cwdStub = sinon . stub ( process , 'cwd' ) . returns ( env . dir ) ;
@@ -493,8 +492,6 @@ describe('Unit: Commands > Update', function () {
493
492
dirs . forEach ( ( version ) => {
494
493
expect ( fs . existsSync ( path . join ( env . dir , version ) ) ) . to . be . true ;
495
494
} ) ;
496
-
497
- env . cleanup ( ) ;
498
495
} ) ;
499
496
} ) ;
500
497
@@ -512,7 +509,7 @@ describe('Unit: Commands > Update', function () {
512
509
'versions/1.5.0'
513
510
]
514
511
} ;
515
- const env = setupEnv ( envCfg ) ;
512
+ const env = setupTestFolder ( envCfg ) ;
516
513
const UpdateCommand = require ( modulePath ) ;
517
514
const instance = new UpdateCommand ( { } , { } ) ;
518
515
const cwdStub = sinon . stub ( process , 'cwd' ) . returns ( env . dir ) ;
@@ -540,8 +537,6 @@ describe('Unit: Commands > Update', function () {
540
537
removedVersions . forEach ( ( version ) => {
541
538
expect ( fs . existsSync ( path . join ( env . dir , 'versions' , version ) ) ) . to . be . false ;
542
539
} ) ;
543
-
544
- env . cleanup ( ) ;
545
540
} ) ;
546
541
} ) ;
547
542
} ) ;
@@ -665,7 +660,7 @@ describe('Unit: Commands > Update', function () {
665
660
dirs : [ 'versions/1.0.0' , 'versions/1.0.1' ] ,
666
661
links : [ [ 'versions/1.0.0' , 'current' ] ]
667
662
}
668
- const env = setupEnv ( envCfg ) ;
663
+ const env = setupTestFolder ( envCfg ) ;
669
664
const cwdStub = sinon . stub ( process , 'cwd' ) . returns ( env . dir ) ;
670
665
const config = configStub ( ) ;
671
666
config . get . withArgs ( 'active-version' ) . returns ( '1.0.0' ) ;
@@ -686,7 +681,6 @@ describe('Unit: Commands > Update', function () {
686
681
expect ( config . save . calledOnce ) . to . be . true ;
687
682
688
683
cwdStub . restore ( ) ;
689
- env . cleanup ( ) ;
690
684
} ) ;
691
685
692
686
it ( 'does things correctly with rollback' , function ( ) {
@@ -695,7 +689,7 @@ describe('Unit: Commands > Update', function () {
695
689
dirs : [ 'versions/1.0.0' , 'versions/1.0.1' ] ,
696
690
links : [ [ 'versions/1.0.1' , 'current' ] ]
697
691
}
698
- const env = setupEnv ( envCfg ) ;
692
+ const env = setupTestFolder ( envCfg ) ;
699
693
const cwdStub = sinon . stub ( process , 'cwd' ) . returns ( env . dir ) ;
700
694
const config = configStub ( ) ;
701
695
config . get . withArgs ( 'active-version' ) . returns ( '1.0.1' ) ;
@@ -716,7 +710,6 @@ describe('Unit: Commands > Update', function () {
716
710
expect ( config . save . calledOnce ) . to . be . true ;
717
711
718
712
cwdStub . restore ( ) ;
719
- env . cleanup ( ) ;
720
713
} ) ;
721
714
} ) ;
722
715
} ) ;
0 commit comments