Skip to content

Commit

Permalink
test(ci): add failing cache config test
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Jan 7, 2020
1 parent f2d770a commit e16f68d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions test/tap/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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})
})
Expand Down Expand Up @@ -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)])
})

0 comments on commit e16f68d

Please sign in to comment.