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:
parent
957f915d42
commit
015623f9ae
5 changed files with 19 additions and 4 deletions
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -9,7 +9,7 @@ uplinks:
|
|||
url: http://localhost:55552/
|
||||
|
||||
packages:
|
||||
'testfwd':
|
||||
'testfwd*':
|
||||
allow_access: all
|
||||
allow_publish: all
|
||||
proxy_access: server2
|
||||
|
|
Loading…
Reference in a new issue