Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 18, 2024
1 parent b64fe99 commit 9d5ccdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions pkg-manager/core/test/install/lockfileDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { prepareEmpty } from '@pnpm/prepare'
import { fixtures } from '@pnpm/test-fixtures'
import { sync as readYamlFile } from 'read-yaml-file'
import { addDependenciesToPackage, mutateModulesInSingleProject } from '@pnpm/core'
import { type DepPath } from '@pnpm/types'
import { sync as rimraf } from '@zkochan/rimraf'
import { testDefaults } from '../utils'

Expand Down Expand Up @@ -54,8 +55,8 @@ test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${
}, testDefaults({ lockfileDir }))

const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz']).toBeTruthy()
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz'].resolution).toHaveProperty(['tarball'], 'file:project/pkg.tgz')
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz' as DepPath]).toBeTruthy()
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz' as DepPath].resolution).toHaveProperty(['tarball'], 'file:project/pkg.tgz')

rimraf('node_modules')

Expand Down
10 changes: 5 additions & 5 deletions pkg-manager/core/test/lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type LockfileFileV9 } from '@pnpm/lockfile-types'
import { tempDir, prepareEmpty, preparePackages } from '@pnpm/prepare'
import { readPackageJsonFromDir } from '@pnpm/read-package-json'
import { addDistTag, getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { type ProjectManifest } from '@pnpm/types'
import { type DepPath, type ProjectManifest } from '@pnpm/types'
import { sync as readYamlFile } from 'read-yaml-file'
import {
addDependenciesToPackage,
Expand Down Expand Up @@ -1380,8 +1380,8 @@ test('a broken lockfile should not break the store', async () => {
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], { ...opts, lockfileOnly: true })

const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
lockfile.packages!['is-positive@1.0.0'].name = 'bad-name'
lockfile.packages!['is-positive@1.0.0'].version = '1.0.0'
lockfile.packages!['is-positive@1.0.0' as DepPath].name = 'bad-name'
lockfile.packages!['is-positive@1.0.0' as DepPath].version = '1.0.0'

writeYamlFile(WANTED_LOCKFILE, lockfile)

Expand All @@ -1391,8 +1391,8 @@ test('a broken lockfile should not break the store', async () => {
rootDir: process.cwd(),
}, testDefaults({ lockfileOnly: true, storeDir: path.resolve('store2') }))

delete lockfile.packages!['is-positive@1.0.0'].name
delete lockfile.packages!['is-positive@1.0.0'].version
delete lockfile.packages!['is-positive@1.0.0' as DepPath].name
delete lockfile.packages!['is-positive@1.0.0' as DepPath].version

writeYamlFile(WANTED_LOCKFILE, lockfile)
rimraf(path.resolve('node_modules'))
Expand Down

0 comments on commit 9d5ccdd

Please sign in to comment.