0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/dos/get-tarball.js
2013-09-27 08:57:09 +04:00

41 lines
908 B
JavaScript
Executable file

#!/usr/bin/env node
var async = require('async');
var assert = require('assert');
var Server = require('../lib/server');
var readfile = require('fs').readFileSync;
var binary = readfile('../fixtures/binary');
var count = 10000;
var server = new Server('http://localhost:55551/');
async.series([
function(cb) {
server.auth('test', 'test', function(res, body) {
cb();
});
},
function(cb) {
server.put_package('testpkg', readfile('../fixtures/test-package.json'), function(res, body) {
cb();
});
},
function(cb) {
server.put_tarball('testpkg', 'blahblah', binary, function(res, body) {
cb();
});
},
function dos(cb) {
server.get_tarball('testpkg', 'blahblah', function(res, body) {
assert(res.statusCode === 200);
assert.deepEqual(body, binary.toString('utf8'));
if (count-- > 0) {
dos(cb);
} else {
cb();
}
});
},
], function() {
process.exit();
});