1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

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

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

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

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

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

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

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

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

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

@ -31,7 +31,7 @@ module.exports = function() {
.status(200) .status(200)
.then(function (body) { .then(function (body) {
// not real sha due to utf8 conversion // 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) .status(200)
.then(function (body) { .then(function (body) {
// not real sha due to utf8 conversion // 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')
}) })
}) })