From e16f68d30d59ce1ddde9fe62f7681b2c07fce84d Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Tue, 7 Jan 2020 11:32:16 -0500 Subject: [PATCH] test(ci): add failing cache config test --- test/tap/ci.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/test/tap/ci.js b/test/tap/ci.js index 3f3e251d03f1..f6359578055b 100644 --- a/test/tap/ci.js +++ b/test/tap/ci.js @@ -12,6 +12,7 @@ const test = require('tap').test const Dir = Tacks.Dir const File = Tacks.File +const cacheDir = common.cache const testDir = common.pkg const EXEC_OPTS = { cwd: testDir } @@ -47,7 +48,7 @@ test('setup', () => { const fixture = new Tacks(Dir({ 'package.json': File(PKG) })) - return rimraf(testDir).then(() => { + return Promise.all([rimraf(cacheDir), rimraf(testDir)]).then(() => { fixture.create(testDir) return mr({port: common.port}) }) @@ -306,7 +307,35 @@ test('errors if package-lock.json invalid', (t) => { ) }) +test('correct cache location when using cache config', (t) => { + const fixture = new Tacks(Dir({ + 'package.json': File(PKG), + 'package-lock.json': File(RAW_LOCKFILE) + })) + return Promise.all([rimraf(cacheDir), rimraf(testDir)]) + .then(() => fixture.create(cacheDir)) + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + `--cache=${cacheDir}`, + '--foo=asdf', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stderr = ret[2] + t.equal(code, 0, 'command completed without error') + t.equal(stderr.trim(), '', 'no output on stderr') + return fs.readdirAsync(path.join(cacheDir, '_cacache')) + }) + .then((modules) => { + t.ok(modules, 'should create _cacache folder') + t.end() + }) +}) + test('cleanup', () => { SERVER.close() - return rimraf(testDir) + return Promise.all([rimraf(cacheDir), rimraf(testDir)]) })