2017-04-19 14:15:28 -05:00
|
|
|
'use strict';
|
2013-12-29 01:40:47 -05:00
|
|
|
|
|
|
|
function readfile(x) {
|
2017-04-19 14:15:28 -05:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x);
|
2013-12-29 01:40:47 -05:00
|
|
|
}
|
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
module.exports = function() {
|
|
|
|
let server = process.server;
|
2014-11-12 06:14:37 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
it('add tag - 404', function() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1').status(404).body_error(/no such package/);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2014-11-12 06:14:37 -05:00
|
|
|
|
|
|
|
describe('addtag', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
before(function() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.putPackage('testpkg-tag', eval(
|
2017-04-19 14:15:28 -05: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() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1-x')
|
2017-04-19 14:15:28 -05:00
|
|
|
.status(404)
|
|
|
|
.body_error(/version doesn't exist/);
|
|
|
|
});
|
2014-11-12 06:14:37 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
it('add tag - bad tag', function() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.addTag('testpkg-tag', 'tag/tag/tag', '0.0.1-x')
|
2017-04-19 14:15:28 -05:00
|
|
|
.status(403)
|
|
|
|
.body_error(/invalid tag/);
|
|
|
|
});
|
2014-11-12 06:14:37 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
it('add tag - good', function() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1')
|
2017-04-19 14:15:28 -05:00
|
|
|
.status(201)
|
|
|
|
.body_ok(/tagged/);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|