Skip to content

Commit

Permalink
chore: standard
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Feb 26, 2018
1 parent 4a99d50 commit c55af02
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
108 changes: 54 additions & 54 deletions packages/libprecious/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,60 @@ test('it works', t => {
}),
'index.js': 'hi'
}, {gzip: true})
.then(tgzData => {
const integrity = ssri.fromData(tgzData).toString()
const fixture = new Tacks(Dir({
'package.json': File({
name: 'foo',
version: '1.2.3',
dependencies: {
bar: '^1.0.0'
}
}),
'package-lock.json': File({
name: 'foo',
lockfileVersion: 1,
requires: true,
dependencies: {
bar: {
version: '1.0.1',
resolved: REGISTRY + 'bar/-/bar-1.0.1.tgz',
integrity
.then(tgzData => {
const integrity = ssri.fromData(tgzData).toString()
const fixture = new Tacks(Dir({
'package.json': File({
name: 'foo',
version: '1.2.3',
dependencies: {
bar: '^1.0.0'
}
}
})
}))
fixture.create(testDir)
const config = mockConfig(testDir, {registry: REGISTRY})
tnock(t, REGISTRY).get('/bar/-/bar-1.0.1.tgz').reply(200, tgzData)
const archivedResolved = `file:archived-packages/bar-1.0.1-${ssri.parse(integrity).hexDigest().slice(0, 9)}.tar`
return new MyPrecious({log: npmlog, config})
.run()
.then(() => fs.readFileAsync('package-lock.json', 'utf8'))
.then(JSON.parse)
.then(pkgLock => {
t.equal(
pkgLock.dependencies.bar.resolved,
archivedResolved,
'resolved field updated in package-lock'
)
return fs.readFileAsync(archivedResolved.substr(5))
.then(tarData => {
const newSri = pkgLock.dependencies.bar.integrity
t.ok(tarData.length > tgzData.length, 'tarball is gunzipped')
t.ok(
ssri.checkData(tarData, newSri),
'archived tarball passes integrity check'
)
t.ok(
ssri.checkData(tgzData, newSri),
'updated integrity field still matches old tgzData'
)
t.notOk(
ssri.checkData('blah', newSri),
'updated integrity field is actually checking data at all'
)
})
}),
'package-lock.json': File({
name: 'foo',
lockfileVersion: 1,
requires: true,
dependencies: {
bar: {
version: '1.0.1',
resolved: REGISTRY + 'bar/-/bar-1.0.1.tgz',
integrity
}
}
})
}))
fixture.create(testDir)
const config = mockConfig(testDir, {registry: REGISTRY})
tnock(t, REGISTRY).get('/bar/-/bar-1.0.1.tgz').reply(200, tgzData)
const archivedResolved = `file:archived-packages/bar-1.0.1-${ssri.parse(integrity).hexDigest().slice(0, 9)}.tar`
return new MyPrecious({log: npmlog, config})
.run()
.then(() => fs.readFileAsync('package-lock.json', 'utf8'))
.then(JSON.parse)
.then(pkgLock => {
t.equal(
pkgLock.dependencies.bar.resolved,
archivedResolved,
'resolved field updated in package-lock'
)
return fs.readFileAsync(archivedResolved.substr(5))
.then(tarData => {
const newSri = pkgLock.dependencies.bar.integrity
t.ok(tarData.length > tgzData.length, 'tarball is gunzipped')
t.ok(
ssri.checkData(tarData, newSri),
'archived tarball passes integrity check'
)
t.ok(
ssri.checkData(tgzData, newSri),
'updated integrity field still matches old tgzData'
)
t.notOk(
ssri.checkData('blah', newSri),
'updated integrity field is actually checking data at all'
)
})
})
})
})
})
2 changes: 1 addition & 1 deletion packages/libprecious/test/util/mock-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function mockConfig (testDir, opts) {

global: false,
group: process.platform === 'win32' ? 0
: process.env.SUDO_GID || (process.getgid && process.getgid()),
: process.env.SUDO_GID || (process.getgid && process.getgid()),
heading: 'npm',
'if-present': false,
'ignore-prepublish': false,
Expand Down
4 changes: 2 additions & 2 deletions packages/libprecious/test/util/mock-tarball.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function makeTarball (files, opts) {
uname: entry.uname,
gname: entry.gname
}, typeof files[filename] === 'string'
? files[filename]
: files[filename].data)
? files[filename]
: files[filename].data)
})
pack.finalize()
return BB.try(() => {
Expand Down

0 comments on commit c55af02

Please sign in to comment.