@@ -12,6 +12,7 @@ const test = require('tap').test
1212
1313const Dir = Tacks . Dir
1414const File = Tacks . File
15+ const cacheDir = common . cache
1516const testDir = common . pkg
1617
1718const EXEC_OPTS = { cwd : testDir }
@@ -47,7 +48,7 @@ test('setup', () => {
4748 const fixture = new Tacks ( Dir ( {
4849 'package.json' : File ( PKG )
4950 } ) )
50- return rimraf ( testDir ) . then ( ( ) => {
51+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] ) . then ( ( ) => {
5152 fixture . create ( testDir )
5253 return mr ( { port : common . port } )
5354 } )
@@ -306,7 +307,35 @@ test('errors if package-lock.json invalid', (t) => {
306307 )
307308} )
308309
310+ test ( 'correct cache location when using cache config' , ( t ) => {
311+ const fixture = new Tacks ( Dir ( {
312+ 'package.json' : File ( PKG ) ,
313+ 'package-lock.json' : File ( RAW_LOCKFILE )
314+ } ) )
315+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] )
316+ . then ( ( ) => fixture . create ( cacheDir ) )
317+ . then ( ( ) => fixture . create ( testDir ) )
318+ . then ( ( ) => common . npm ( [
319+ 'ci' ,
320+ `--cache=${ cacheDir } ` ,
321+ '--foo=asdf' ,
322+ '--registry' , common . registry ,
323+ '--loglevel' , 'warn'
324+ ] , EXEC_OPTS ) )
325+ . then ( ( ret ) => {
326+ const code = ret [ 0 ]
327+ const stderr = ret [ 2 ]
328+ t . equal ( code , 0 , 'command completed without error' )
329+ t . equal ( stderr . trim ( ) , '' , 'no output on stderr' )
330+ return fs . readdirAsync ( path . join ( cacheDir , '_cacache' ) )
331+ } )
332+ . then ( ( modules ) => {
333+ t . ok ( modules , 'should create _cacache folder' )
334+ t . end ( )
335+ } )
336+ } )
337+
309338test ( 'cleanup' , ( ) => {
310339 SERVER . close ( )
311- return rimraf ( testDir )
340+ return Promise . all ( [ rimraf ( cacheDir ) , rimraf ( testDir ) ] )
312341} )
0 commit comments