11cb0ef41Sopenharmony_ciconst t = require('tap')
21cb0ef41Sopenharmony_ciconst { load: loadMockNpm } = require('../../fixtures/mock-npm.js')
31cb0ef41Sopenharmony_ciconst MockRegistry = require('@npmcli/mock-registry')
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst cacache = require('cacache')
61cb0ef41Sopenharmony_ciconst fs = require('fs')
71cb0ef41Sopenharmony_ciconst path = require('path')
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst pkg = 'test-package'
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cit.cleanSnapshot = str => {
121cb0ef41Sopenharmony_ci  return str
131cb0ef41Sopenharmony_ci    .replace(/Finished in [0-9.s]+/g, 'Finished in xxxs')
141cb0ef41Sopenharmony_ci    .replace(/Cache verified and compressed (.*)/, 'Cache verified and compressed ({PATH})')
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cit.test('cache no args', async t => {
181cb0ef41Sopenharmony_ci  const { npm } = await loadMockNpm(t)
191cb0ef41Sopenharmony_ci  await t.rejects(
201cb0ef41Sopenharmony_ci    npm.exec('cache', []),
211cb0ef41Sopenharmony_ci    { code: 'EUSAGE' },
221cb0ef41Sopenharmony_ci    'should throw usage instructions'
231cb0ef41Sopenharmony_ci  )
241cb0ef41Sopenharmony_ci})
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_cit.test('cache clean', async t => {
271cb0ef41Sopenharmony_ci  const { npm } = await loadMockNpm(t)
281cb0ef41Sopenharmony_ci  await t.rejects(
291cb0ef41Sopenharmony_ci    npm.exec('cache', ['clean']),
301cb0ef41Sopenharmony_ci    /the npm cache self-heals/,
311cb0ef41Sopenharmony_ci    'should throw warning'
321cb0ef41Sopenharmony_ci  )
331cb0ef41Sopenharmony_ci})
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_cit.test('cache clean (force)', async t => {
361cb0ef41Sopenharmony_ci  const { npm } = await loadMockNpm(t, {
371cb0ef41Sopenharmony_ci    cacheDir: { _cacache: {} },
381cb0ef41Sopenharmony_ci    config: { force: true },
391cb0ef41Sopenharmony_ci  })
401cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
411cb0ef41Sopenharmony_ci  await npm.exec('cache', ['clean'])
421cb0ef41Sopenharmony_ci  t.notOk(fs.existsSync(cache), 'cache dir was removed')
431cb0ef41Sopenharmony_ci})
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_cit.test('cache add no arg', async t => {
461cb0ef41Sopenharmony_ci  const { npm } = await loadMockNpm(t)
471cb0ef41Sopenharmony_ci  await t.rejects(
481cb0ef41Sopenharmony_ci    npm.exec('cache', ['add']),
491cb0ef41Sopenharmony_ci    {
501cb0ef41Sopenharmony_ci      code: 'EUSAGE',
511cb0ef41Sopenharmony_ci      message: 'First argument to `add` is required',
521cb0ef41Sopenharmony_ci    },
531cb0ef41Sopenharmony_ci    'throws usage error'
541cb0ef41Sopenharmony_ci  )
551cb0ef41Sopenharmony_ci})
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_cit.test('cache add single pkg', async t => {
581cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t, {
591cb0ef41Sopenharmony_ci    prefixDir: {
601cb0ef41Sopenharmony_ci      package: {
611cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
621cb0ef41Sopenharmony_ci          name: pkg,
631cb0ef41Sopenharmony_ci          version: '1.0.0',
641cb0ef41Sopenharmony_ci        }),
651cb0ef41Sopenharmony_ci      },
661cb0ef41Sopenharmony_ci    },
671cb0ef41Sopenharmony_ci  })
681cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
691cb0ef41Sopenharmony_ci  const registry = new MockRegistry({
701cb0ef41Sopenharmony_ci    tap: t,
711cb0ef41Sopenharmony_ci    registry: npm.config.get('registry'),
721cb0ef41Sopenharmony_ci  })
731cb0ef41Sopenharmony_ci  const manifest = registry.manifest({ name: pkg })
741cb0ef41Sopenharmony_ci  await registry.package({ manifest, tarballs: { '1.0.0': path.join(npm.prefix, 'package') } })
751cb0ef41Sopenharmony_ci  await npm.exec('cache', ['add', pkg])
761cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '')
771cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
781cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
791cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
801cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
811cb0ef41Sopenharmony_ci})
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_cit.test('cache add multiple pkgs', async t => {
841cb0ef41Sopenharmony_ci  const pkg2 = 'test-package-two'
851cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t, {
861cb0ef41Sopenharmony_ci    prefixDir: {
871cb0ef41Sopenharmony_ci      package: {
881cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
891cb0ef41Sopenharmony_ci          name: pkg,
901cb0ef41Sopenharmony_ci          version: '1.0.0',
911cb0ef41Sopenharmony_ci        }),
921cb0ef41Sopenharmony_ci      },
931cb0ef41Sopenharmony_ci    },
941cb0ef41Sopenharmony_ci  })
951cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
961cb0ef41Sopenharmony_ci  const registry = new MockRegistry({
971cb0ef41Sopenharmony_ci    tap: t,
981cb0ef41Sopenharmony_ci    registry: npm.config.get('registry'),
991cb0ef41Sopenharmony_ci  })
1001cb0ef41Sopenharmony_ci  const manifest = registry.manifest({ name: pkg })
1011cb0ef41Sopenharmony_ci  const manifest2 = registry.manifest({ name: pkg2 })
1021cb0ef41Sopenharmony_ci  await registry.package({ manifest, tarballs: { '1.0.0': path.join(npm.prefix, 'package') } })
1031cb0ef41Sopenharmony_ci  await registry.package({
1041cb0ef41Sopenharmony_ci    manifest: manifest2, tarballs: { '1.0.0': path.join(npm.prefix, 'package') },
1051cb0ef41Sopenharmony_ci  })
1061cb0ef41Sopenharmony_ci  await npm.exec('cache', ['add', pkg, pkg2])
1071cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '')
1081cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
1091cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
1101cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
1111cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
1121cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
1131cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package-two/-/test-package-two-1.0.0.tgz'))
1141cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
1151cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package-two'))
1161cb0ef41Sopenharmony_ci})
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_cit.test('cache ls', async t => {
1191cb0ef41Sopenharmony_ci  const keys = [
1201cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package',
1211cb0ef41Sopenharmony_ci    // eslint-disable-next-line max-len
1221cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz',
1231cb0ef41Sopenharmony_ci  ]
1241cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
1251cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
1261cb0ef41Sopenharmony_ci  for (const key of keys) {
1271cb0ef41Sopenharmony_ci    await cacache.put(cache, key, 'test data')
1281cb0ef41Sopenharmony_ci  }
1291cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls'])
1301cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entries')
1311cb0ef41Sopenharmony_ci})
1321cb0ef41Sopenharmony_ci
1331cb0ef41Sopenharmony_cit.test('cache ls pkgs', async t => {
1341cb0ef41Sopenharmony_ci  const keys = [
1351cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/npm',
1361cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/npm/-/npm-1.2.0.tgz',
1371cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/webpack/-/webpack-4.47.0.tgz',
1381cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/webpack/-/webpack-4.40.0.tgz',
1391cb0ef41Sopenharmony_ci  ]
1401cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
1411cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
1421cb0ef41Sopenharmony_ci  for (const key of keys) {
1431cb0ef41Sopenharmony_ci    await cacache.put(cache, key, 'test data')
1441cb0ef41Sopenharmony_ci  }
1451cb0ef41Sopenharmony_ci  await cacache.put(cache,
1461cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/webpack',
1471cb0ef41Sopenharmony_ci    JSON.stringify({ versions: {
1481cb0ef41Sopenharmony_ci      '4.40.0': { dist: { tarball: 'https://registry.npmjs.org/webpack/-/webpack-4.40.0.tgz' } },
1491cb0ef41Sopenharmony_ci      '4.47.0': { dist: { tarball: 'https://registry.npmjs.org/webpack/-/webpack-4.47.0.tgz' } },
1501cb0ef41Sopenharmony_ci    } })
1511cb0ef41Sopenharmony_ci  )
1521cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', 'webpack@>4.44.1', 'npm'])
1531cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entries for npm and webpack and one webpack tgz')
1541cb0ef41Sopenharmony_ci})
1551cb0ef41Sopenharmony_ci
1561cb0ef41Sopenharmony_cit.test('cache ls special', async t => {
1571cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
1581cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
1591cb0ef41Sopenharmony_ci  await cacache.put(cache,
1601cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/foo',
1611cb0ef41Sopenharmony_ci    JSON.stringify({ versions: { '1.2.3-beta': {} } })
1621cb0ef41Sopenharmony_ci  )
1631cb0ef41Sopenharmony_ci  await cacache.put(cache,
1641cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/foo/-/foo-1.2.3-beta.tgz',
1651cb0ef41Sopenharmony_ci    'test-data'
1661cb0ef41Sopenharmony_ci  )
1671cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', 'foo@1.2.3-beta'])
1681cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entries for foo')
1691cb0ef41Sopenharmony_ci})
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_cit.test('cache ls nonpublic registry', async t => {
1721cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
1731cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
1741cb0ef41Sopenharmony_ci  await cacache.put(cache,
1751cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://somerepo.github.org/extemporaneously',
1761cb0ef41Sopenharmony_ci    JSON.stringify({
1771cb0ef41Sopenharmony_ci      versions: { '1.0.0': { dist: { tarball: 'https://somerepo.github.org/aabbcc/' } } },
1781cb0ef41Sopenharmony_ci    })
1791cb0ef41Sopenharmony_ci  )
1801cb0ef41Sopenharmony_ci  await cacache.put(cache,
1811cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://somerepo.github.org/aabbcc/',
1821cb0ef41Sopenharmony_ci    'test data'
1831cb0ef41Sopenharmony_ci  )
1841cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', 'extemporaneously'])
1851cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entry for extemporaneously and its tarball')
1861cb0ef41Sopenharmony_ci})
1871cb0ef41Sopenharmony_ci
1881cb0ef41Sopenharmony_cit.test('cache ls tagged', async t => {
1891cb0ef41Sopenharmony_ci  const { npm } = await loadMockNpm(t)
1901cb0ef41Sopenharmony_ci  await t.rejects(
1911cb0ef41Sopenharmony_ci    npm.exec('cache', ['ls', 'webpack@latest']),
1921cb0ef41Sopenharmony_ci    { code: 'EUSAGE' },
1931cb0ef41Sopenharmony_ci    'should throw usage error'
1941cb0ef41Sopenharmony_ci  )
1951cb0ef41Sopenharmony_ci})
1961cb0ef41Sopenharmony_ci
1971cb0ef41Sopenharmony_cit.test('cache ls scoped and scoped slash', async t => {
1981cb0ef41Sopenharmony_ci  const keys = [
1991cb0ef41Sopenharmony_ci    // eslint-disable-next-line max-len
2001cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/@fritzy/staydown/-/@fritzy/staydown-3.1.1.tgz',
2011cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/@fritzy%2fstaydown',
2021cb0ef41Sopenharmony_ci    // eslint-disable-next-line max-len
2031cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/@gar/npm-expansion/-/@gar/npm-expansion-2.1.0.tgz',
2041cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/@gar%2fnpm-expansion',
2051cb0ef41Sopenharmony_ci  ]
2061cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2071cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
2081cb0ef41Sopenharmony_ci  for (const key of keys) {
2091cb0ef41Sopenharmony_ci    await cacache.put(cache, key, 'test data')
2101cb0ef41Sopenharmony_ci  }
2111cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', '@fritzy/staydown', '@gar/npm-expansion'])
2121cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entries for @gar and @fritzy')
2131cb0ef41Sopenharmony_ci})
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_cit.test('cache ls corrupted', async t => {
2161cb0ef41Sopenharmony_ci  const keys = [
2171cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/corrupted',
2181cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/corrupted/-/corrupted-3.1.0.tgz',
2191cb0ef41Sopenharmony_ci  ]
2201cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2211cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
2221cb0ef41Sopenharmony_ci  for (const key of keys) {
2231cb0ef41Sopenharmony_ci    await cacache.put(cache, key, Buffer.from('<>>>}"'))
2241cb0ef41Sopenharmony_ci  }
2251cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', 'corrupted'])
2261cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entries with bad data')
2271cb0ef41Sopenharmony_ci})
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_cit.test('cache ls missing packument version not an object', async t => {
2301cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2311cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
2321cb0ef41Sopenharmony_ci  await cacache.put(cache,
2331cb0ef41Sopenharmony_ci    'make-fetch-happen:request-cache:https://registry.npmjs.org/missing-version',
2341cb0ef41Sopenharmony_ci    JSON.stringify({ versions: 'not an object' })
2351cb0ef41Sopenharmony_ci  )
2361cb0ef41Sopenharmony_ci  await npm.exec('cache', ['ls', 'missing-version'])
2371cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs cache entry for packument')
2381cb0ef41Sopenharmony_ci})
2391cb0ef41Sopenharmony_ci
2401cb0ef41Sopenharmony_cit.test('cache rm', async t => {
2411cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2421cb0ef41Sopenharmony_ci  const cache = path.join(npm.cache, '_cacache')
2431cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
2441cb0ef41Sopenharmony_ci  await cacache.put(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package', '{}')
2451cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
2461cb0ef41Sopenharmony_ci  await cacache.put(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz', 'test data')
2471cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
2481cb0ef41Sopenharmony_ci  await npm.exec('cache', ['rm', 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'])
2491cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'logs deleting single entry')
2501cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
2511cb0ef41Sopenharmony_ci  t.resolves(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package'))
2521cb0ef41Sopenharmony_ci  // eslint-disable-next-line max-len
2531cb0ef41Sopenharmony_ci  t.rejects(cacache.get(cache, 'make-fetch-happen:request-cache:https://registry.npmjs.org/test-package/-/test-package-1.0.0.tgz'))
2541cb0ef41Sopenharmony_ci})
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_cit.test('cache rm unfound', async t => {
2571cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2581cb0ef41Sopenharmony_ci  await npm.exec('cache', ['rm', 'made-up-key'])
2591cb0ef41Sopenharmony_ci  t.same(joinedOutput(), '', 'no errors, no output')
2601cb0ef41Sopenharmony_ci})
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_cit.test('cache verify', async t => {
2631cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t)
2641cb0ef41Sopenharmony_ci  await npm.exec('cache', ['verify'])
2651cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'shows verified cache output')
2661cb0ef41Sopenharmony_ci})
2671cb0ef41Sopenharmony_ci
2681cb0ef41Sopenharmony_cit.test('cache verify as part of home', async t => {
2691cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t, {
2701cb0ef41Sopenharmony_ci    globals: ({ prefix }) => ({ 'process.env.HOME': path.dirname(prefix) }),
2711cb0ef41Sopenharmony_ci  })
2721cb0ef41Sopenharmony_ci  await npm.exec('cache', ['verify'])
2731cb0ef41Sopenharmony_ci  t.match(joinedOutput(), 'Cache verified and compressed (~', 'contains ~ shorthand')
2741cb0ef41Sopenharmony_ci})
2751cb0ef41Sopenharmony_ci
2761cb0ef41Sopenharmony_cit.test('cache verify w/ extra output', async t => {
2771cb0ef41Sopenharmony_ci  const verify = {
2781cb0ef41Sopenharmony_ci    runTime: {
2791cb0ef41Sopenharmony_ci      markStartTime: 0,
2801cb0ef41Sopenharmony_ci      fixPerms: 3,
2811cb0ef41Sopenharmony_ci      garbageCollect: 54982,
2821cb0ef41Sopenharmony_ci      rebuildIndex: 62779,
2831cb0ef41Sopenharmony_ci      cleanTmp: 62781,
2841cb0ef41Sopenharmony_ci      writeVerifile: 62783,
2851cb0ef41Sopenharmony_ci      markEndTime: 62783,
2861cb0ef41Sopenharmony_ci      total: 62783,
2871cb0ef41Sopenharmony_ci    },
2881cb0ef41Sopenharmony_ci    verifiedContent: 17057,
2891cb0ef41Sopenharmony_ci    reclaimedCount: 1144,
2901cb0ef41Sopenharmony_ci    reclaimedSize: 248164665,
2911cb0ef41Sopenharmony_ci    badContentCount: 12345,
2921cb0ef41Sopenharmony_ci    keptSize: 1644485260,
2931cb0ef41Sopenharmony_ci    missingContent: 92,
2941cb0ef41Sopenharmony_ci    rejectedEntries: 92,
2951cb0ef41Sopenharmony_ci    totalEntries: 20175,
2961cb0ef41Sopenharmony_ci  }
2971cb0ef41Sopenharmony_ci  const { npm, joinedOutput } = await loadMockNpm(t, {
2981cb0ef41Sopenharmony_ci    mocks: { cacache: { verify: () => verify } },
2991cb0ef41Sopenharmony_ci  })
3001cb0ef41Sopenharmony_ci  await npm.exec('cache', ['verify'])
3011cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'shows extra output')
3021cb0ef41Sopenharmony_ci})
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_cit.test('cache completion', async t => {
3051cb0ef41Sopenharmony_ci  const { cache } = await loadMockNpm(t, { command: 'cache' })
3061cb0ef41Sopenharmony_ci  const { completion } = cache
3071cb0ef41Sopenharmony_ci
3081cb0ef41Sopenharmony_ci  const testComp = (argv, expect) => {
3091cb0ef41Sopenharmony_ci    return t.resolveMatch(completion({ conf: { argv: { remain: argv } } }), expect, argv.join(' '))
3101cb0ef41Sopenharmony_ci  }
3111cb0ef41Sopenharmony_ci
3121cb0ef41Sopenharmony_ci  await Promise.all([
3131cb0ef41Sopenharmony_ci    testComp(['npm', 'cache'], ['add', 'clean', 'verify']),
3141cb0ef41Sopenharmony_ci    testComp(['npm', 'cache', 'add'], []),
3151cb0ef41Sopenharmony_ci    testComp(['npm', 'cache', 'clean'], []),
3161cb0ef41Sopenharmony_ci    testComp(['npm', 'cache', 'verify'], []),
3171cb0ef41Sopenharmony_ci  ])
3181cb0ef41Sopenharmony_ci})
319