2013-12-29 07:40:47 +01:00
|
|
|
|
|
|
|
function readfile(x) {
|
2014-11-12 12:14:37 +01:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x)
|
2013-12-29 07:40:47 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
module.exports = function () {
|
2014-11-12 12:14:37 +01:00
|
|
|
var server = process.server
|
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('add tag - 404', function () {
|
|
|
|
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/no such package/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('addtag', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
before(function () {
|
|
|
|
return server.put_package('testpkg-tag', eval(
|
|
|
|
'(' + readfile('fixtures/publish.json5')
|
|
|
|
.toString('utf8')
|
|
|
|
.replace(/__NAME__/g, 'testpkg-tag')
|
|
|
|
.replace(/__VERSION__/g, '0.0.1')
|
|
|
|
+ ')'
|
|
|
|
)).status(201)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('add testpkg-tag', function(){})
|
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('add tag - bad ver', function () {
|
|
|
|
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1-x')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/version doesn't exist/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('add tag - bad tag', function () {
|
|
|
|
return server.add_tag('testpkg-tag', 'tag/tag/tag', '0.0.1-x')
|
|
|
|
.status(403)
|
|
|
|
.body_error(/invalid tag/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('add tag - good', function () {
|
|
|
|
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1')
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/tagged/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
})
|
2013-12-29 07:40:47 +01:00
|
|
|
}
|