0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00
verdaccio/test/functional/addtag.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
2013-12-29 10:40:47 +04:00
function readfile(x) {
2017-04-19 21:15:28 +02:00
return require('fs').readFileSync(__dirname + '/' + x);
2013-12-29 10:40:47 +04:00
}
2017-04-19 21:15:28 +02:00
module.exports = function() {
let server = process.server;
2017-04-19 21:15:28 +02:00
it('add tag - 404', function() {
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1').status(404).body_error(/no such package/);
});
describe('addtag', function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server.put_package('testpkg-tag', eval(
2017-04-19 21:15:28 +02:00
'(' + readfile('fixtures/publish.json5')
.toString('utf8')
.replace(/__NAME__/g, 'testpkg-tag')
.replace(/__VERSION__/g, '0.0.1')
+ ')'
)).status(201);
});
it('add testpkg-tag', function() {
// TODO: ?
});
it('add tag - bad ver', function() {
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1-x')
2017-04-19 21:15:28 +02:00
.status(404)
.body_error(/version doesn't exist/);
});
2017-04-19 21:15:28 +02:00
it('add tag - bad tag', function() {
return server.add_tag('testpkg-tag', 'tag/tag/tag', '0.0.1-x')
2017-04-19 21:15:28 +02:00
.status(403)
.body_error(/invalid tag/);
});
2017-04-19 21:15:28 +02:00
it('add tag - good', function() {
return server.add_tag('testpkg-tag', 'tagtagtag', '0.0.1')
2017-04-19 21:15:28 +02:00
.status(201)
.body_ok(/tagged/);
});
});
};