0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/functional/addtag.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-12-29 01:40:47 -05:00
var assert = require('assert')
function readfile(x) {
return require('fs').readFileSync(__dirname + '/' + x)
2013-12-29 01:40:47 -05:00
}
module.exports = function() {
var server = process.server
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'))
cb()
})
})
describe('addtag', function() {
before(function(cb) {
server.put_package('testpkg-tag', eval(
'(' + readfile('fixtures/publish.json5')
.toString('utf8')
.replace(/__NAME__/g, 'testpkg-tag')
.replace(/__VERSION__/g, '0.0.1')
+ ')'
), function(res, body) {
assert.equal(res.statusCode, 201)
cb()
})
})
it('add testpkg-tag', 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'))
cb()
})
})
it('add tag - bad tag', function(cb) {
server.add_tag('testpkg-tag', 'tag/tag/tag', '0.0.1-x', function(res, body) {
assert.equal(res.statusCode, 403)
assert(~body.error.indexOf('invalid tag'))
cb()
})
})
it('add tag - good', function(cb) {
server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1', function(res, body) {
assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('tagged'))
cb()
})
})
})
2013-12-29 01:40:47 -05:00
}