Skip to content

Commit

Permalink
fix logs and tests for rlidwka#56
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Mar 13, 2014
1 parent d657e18 commit df49fb8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.error
res._sinopia_error = body.reason || body.error
}
body = JSON.stringify(body, undefined, '\t') + '\n'
}
Expand Down
6 changes: 4 additions & 2 deletions test/functional/addtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ 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(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand All @@ -34,7 +35,8 @@ 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(~body.error.indexOf('version doesn\'t exist'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('version doesn\'t exist'))
cb()
})
})
Expand Down
9 changes: 6 additions & 3 deletions test/functional/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand All @@ -28,7 +29,8 @@ module.exports = function() {
it('downloading non-existent tarball', function(cb) {
server.get_tarball('testpkg', 'blahblah', function(res, body) {
assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such file'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such file'))
cb()
})
})
Expand Down Expand Up @@ -109,7 +111,8 @@ 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(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand Down
6 changes: 4 additions & 2 deletions test/functional/gh29.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ 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(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand All @@ -32,7 +33,8 @@ 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(~body.error.indexOf('no such file'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such file'))
cb()
})
})
Expand Down
3 changes: 2 additions & 1 deletion test/functional/mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = function() {
it('testing anti-loop', function(cb) {
server2.get_package('testloop', function(res, body) {
assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand Down
3 changes: 2 additions & 1 deletion test/functional/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = function() {
server.get_package('testexp_tags', function(res, body) {
// shouldn't exist yet
assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package'))
assert.equal(body.error, 'not_found')
assert(~body.reason.indexOf('no such package'))
cb()
})
})
Expand Down

0 comments on commit df49fb8

Please sign in to comment.