diff --git a/lib/middleware.js b/lib/middleware.js index 9517ac2c7..6bd83fbab 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -133,7 +133,7 @@ module.exports.log_and_etagify = function(req, res, next) { if (typeof(body) === 'object' && body != null) { if (body.error) { - res._sinopia_error = body.reason || body.error + res._sinopia_error = body.error } body = JSON.stringify(body, undefined, '\t') + '\n' } diff --git a/test/functional/addtag.js b/test/functional/addtag.js index 08dfdff53..593f5658b 100644 --- a/test/functional/addtag.js +++ b/test/functional/addtag.js @@ -10,8 +10,7 @@ module.exports = function() { it('add tag - 404', function(cb) { server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) }) @@ -35,8 +34,7 @@ module.exports = function() { it('add tag - bad ver', function(cb) { server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1-x', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('version doesn\'t exist')) + assert(~body.error.indexOf('version doesn\'t exist')) cb() }) }) diff --git a/test/functional/basic.js b/test/functional/basic.js index e2bc202ab..d285770d3 100644 --- a/test/functional/basic.js +++ b/test/functional/basic.js @@ -15,8 +15,7 @@ module.exports = function() { it('trying to fetch non-existent package', function(cb) { server.get_package('testpkg', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) }) @@ -29,8 +28,7 @@ module.exports = function() { it('downloading non-existent tarball', function(cb) { server.get_tarball('testpkg', 'blahblah', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such file')) + assert(~body.error.indexOf('no such file')) cb() }) }) @@ -111,8 +109,7 @@ module.exports = function() { it('uploading new package version for bad pkg', function(cb) { server.put_version('testpxg', '0.0.1', require('./lib/package')('testpxg'), function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) }) diff --git a/test/functional/gh29.js b/test/functional/gh29.js index 603bc30c6..3847db5d8 100644 --- a/test/functional/gh29.js +++ b/test/functional/gh29.js @@ -13,8 +13,7 @@ module.exports = function() { it('downloading non-existent tarball #1 / srv2', function(cb) { server2.get_tarball('testpkg-gh29', 'blahblah', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) }) @@ -33,8 +32,7 @@ module.exports = function() { it('downloading non-existent tarball #2 / srv2', function(cb) { server2.get_tarball('testpkg-gh29', 'blahblah', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such file')) + assert(~body.error.indexOf('no such file')) cb() }) }) diff --git a/test/functional/mirror.js b/test/functional/mirror.js index 4234299e3..76206e9d8 100644 --- a/test/functional/mirror.js +++ b/test/functional/mirror.js @@ -12,8 +12,7 @@ module.exports = function() { it('testing anti-loop', function(cb) { server2.get_package('testloop', function(res, body) { assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) }) diff --git a/test/functional/tags.js b/test/functional/tags.js index 81196c046..53d93dbfc 100644 --- a/test/functional/tags.js +++ b/test/functional/tags.js @@ -13,8 +13,7 @@ module.exports = function() { server.get_package('testexp_tags', function(res, body) { // shouldn't exist yet assert.equal(res.statusCode, 404) - assert.equal(body.error, 'not_found') - assert(~body.reason.indexOf('no such package')) + assert(~body.error.indexOf('no such package')) cb() }) })