Files
pnpm/test/cache.ts
Zoltan Kochan b9104a457c feat(global): change default global path
Use ~/.pnpm-cache as the default cache path.
Use the Node path for hosting the global pnpm package.
2017-01-21 18:38:47 +02:00

62 lines
1.8 KiB
TypeScript

import {cleanCache, installPkgs, install} from '../src'
import {add as addDistTag} from './support/distTags'
import testDefaults from './support/testDefaults'
import tape = require('tape')
import promisifyTape from 'tape-promise'
import exists = require('exists-file')
import path = require('path')
import prepare from './support/prepare'
const test = promisifyTape(tape)
test('cache clean removes cache', async function (t) {
prepare(t)
const opts = testDefaults({global: true})
await installPkgs(['is-positive'], opts)
t.ok(await exists(opts.cachePath), 'cache is created')
await cleanCache(opts.cachePath)
t.ok(!await exists(opts.cachePath), 'cache is removed')
})
test('should fail to update when requests are cached', async function (t) {
const project = prepare(t)
const latest = 'stable'
const cacheTTL = 60 * 60
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, tag: latest, cacheTTL}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
await install(testDefaults({depth: 1, tag: latest, cacheTTL}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
})
test('should skip cahe even if it exists when cacheTTL = 0', async function (t) {
const project = prepare(t)
const latest = 'stable'
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, tag: latest, cacheTTL: 60 * 60}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
await install(testDefaults({depth: 1, tag: latest, cacheTTL: 0}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
})