0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

making various test cases work

This commit is contained in:
Alex Kocharin 2013-10-11 13:50:41 +04:00
parent 957f915d42
commit 015623f9ae
5 changed files with 19 additions and 4 deletions

View file

@ -50,6 +50,7 @@ function write_stream(name) {
var tmpname = name + '.tmp-'+String(Math.random()).replace(/^0\./, '');
var file = fs.createWriteStream(tmpname);
var opened = false;
stream.pipe(file);
stream.done = function() {
@ -69,12 +70,16 @@ function write_stream(name) {
}
};
stream.abort = function() {
if (opened) {
opened = false;
file.on('close', function() {
fs.unlink(tmpname, function(){});
});
}
file.destroySoon();
};
file.on('open', function() {
opened = true;
// re-emitting open because it's handled in storage.js
stream.emit('open');
});

View file

@ -277,6 +277,7 @@ Storage.prototype.get_tarball = function(name, filename) {
var savestream = self.local.add_tarball(name, filename);
savestream.on('error', function(err) {
savestream.abort();
stream.emit('error', err);
});
savestream.on('open', function() {

View file

@ -49,6 +49,7 @@ Storage.prototype.request = function(options, cb) {
if (typeof(options.json) === 'object' && options.json != null) {
var json = JSON.stringify(options.json);
headers['content-type'] = headers['content-type'] || 'application/json';
}
var req = request({

View file

@ -43,6 +43,14 @@ ex['uploading new tarball'] = function(cb) {
});
};
ex['doubleerr test'] = function(cb) {
server.put_tarball('testfwd2', 'blahblah', readfile('fixtures/binary'), function(res, body) {
assert.equal(res.statusCode, 404);
assert(body.error);
cb();
});
};
ex['downloading newly created tarball'] = function(cb) {
server.get_tarball('testpkg', 'blahblah', function(res, body) {
assert.equal(res.statusCode, 200);

View file

@ -9,7 +9,7 @@ uplinks:
url: http://localhost:55552/
packages:
'testfwd':
'testfwd*':
allow_access: all
allow_publish: all
proxy_access: server2