Fix tests for node 6

Node 6 introduced two breaking changes to verdaccio/sinopia
Path functions now throw on null/undefined arguments
Buffer defaults to binary now A lot of test code explicitly converted data to utf8 which broke on checksum
This commit is contained in:
trent.earl 2016-07-30 14:02:50 -05:00
parent cafbb5f76b
commit dd406da3e2
9 changed files with 16 additions and 10 deletions

View File

@ -36,7 +36,7 @@ function Config(config) {
assert(self.storage, 'CONFIG: storage path not defined')
self.localList = LocalData(
Path.join(
Path.resolve(Path.dirname(self.self_path), self.storage),
Path.resolve(Path.dirname(self.self_path || ''), self.storage),
'.sinopia-db.json'
)
)

View File

@ -663,7 +663,7 @@ Storage.prototype.storage = function(package) {
}
return Path_Wrapper(
Path.join(
Path.resolve(Path.dirname(this.config.self_path), path),
Path.resolve(Path.dirname(this.config.self_path || ''), path),
package
)
)

View File

@ -43,7 +43,7 @@ module.exports = function () {
return server.get_tarball('testpkg', 'blahblah')
.status(200)
.then(function (body) {
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
assert.deepEqual(body, readfile('fixtures/binary'))
})
})

View File

@ -54,7 +54,7 @@ module.exports = function() {
return server2.get_tarball('testpkg-gh29', 'blahblah')
.status(200)
.then(function (body) {
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
assert.deepEqual(body, readfile('fixtures/binary'))
})
})
})

View File

@ -76,6 +76,7 @@ Server.prototype.get_tarball = function(name, filename) {
return this.request({
uri: '/'+encodeURIComponent(name)+'/-/'+encodeURIComponent(filename),
method: 'GET',
encoding: null
})
}

View File

@ -53,7 +53,7 @@ module.exports = function() {
return server.get_tarball(pkg, pkg+'.file')
.status(200)
.then(function (body) {
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
assert.deepEqual(body, readfile('fixtures/binary'))
})
})
})

View File

@ -32,7 +32,7 @@ module.exports = function() {
.status(200)
.then(function (body) {
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), '789ca61e3426ce55c4983451b58e62b04abceaf6')
assert.strictEqual(sha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863')
})
})
@ -41,7 +41,7 @@ module.exports = function() {
.status(200)
.then(function (body) {
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), '789ca61e3426ce55c4983451b58e62b04abceaf6')
assert.strictEqual(sha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863')
})
})

View File

@ -51,7 +51,7 @@ module.exports = function() {
return server.get_tarball('test-nullstorage2', 'blahblah')
.status(200)
.then(function (body) {
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
assert.deepEqual(body, readfile('fixtures/binary'))
})
})

View File

@ -31,7 +31,7 @@ module.exports = function() {
.status(200)
.then(function (body) {
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), 'c59298948907d077c3b42f091554bdeea9208964')
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790')
})
})
@ -40,7 +40,12 @@ module.exports = function() {
.status(200)
.then(function (body) {
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), 'c59298948907d077c3b42f091554bdeea9208964')
require('fs').writeFileSync(
'/Users/trent.earl/what.tgz',
body
);
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790')
})
})