0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

moving unit tests to separate folder

This commit is contained in:
Alex Kocharin 2013-12-16 00:54:50 +04:00
parent 693aa576b4
commit d5d2a8bdcc
7 changed files with 48 additions and 48 deletions

View file

@ -1 +0,0 @@
stuff used for stress-testing, using against real servers is unadvisable

View file

@ -1,41 +0,0 @@
#!/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();
});

View file

@ -4,7 +4,7 @@ CWD=$(pwd)
PATH='../node_modules/.bin':$PATH
TESTDIR=$(dirname $0)
cd $TESTDIR
mocha -R list --ui exports ./tests.js ./no_proxy.js ./st_merge.js
mocha -R list --ui exports ./tests.js ./unit
TESTRES=$?
cd $CWD
exit $TESTRES

View file

@ -1,7 +1,7 @@
var assert = require('assert')
, Storage = require('../lib/up-storage')
, Storage = require('../../lib/up-storage')
require('../lib/logger').setup()
require('../../lib/logger').setup()
function setup(host, config, mainconfig) {
config.url = host

View file

@ -1,6 +1,6 @@
var assert = require('assert')
, semver_sort = require('../lib/storage')._semver_sort
, merge = require('../lib/storage')._merge_versions
, semver_sort = require('../../lib/storage')._semver_sort
, merge = require('../../lib/storage')._merge_versions
//require('../lib/logger').setup()

View file

@ -1,4 +1,4 @@
var transaction = require('../lib/transaction')
var transaction = require('../../lib/transaction')
var assert = require('assert')
function call_back(cb, value) {

42
test/unit/utils.js Normal file
View file

@ -0,0 +1,42 @@
var assert = require('assert')
, validate = require('../../lib/utils').validate_name
exports['Validate'] = {
'good ones': function() {
assert(validate('sinopia'))
assert(validate('some.weird.package-zzz'))
},
'uppercase': function() {
assert(validate('EVE'))
assert(validate('JSONStream'))
},
'no package.json': function() {
assert(!validate('package.json'))
},
'no path seps': function() {
assert(!validate('some/thing'))
assert(!validate('some\\thing'))
},
'no hidden': function() {
assert(!validate('.bin'))
},
'no reserved': function() {
assert(!validate('favicon.ico'))
assert(!validate('node_modules'))
assert(!validate('__proto__'))
},
'other': function() {
assert(!validate('pkg@'))
assert(!validate('pk g'))
assert(!validate('pk\tg'))
assert(!validate('pk%20g'))
assert(!validate('pk+g'))
assert(!validate('pk:g'))
},
}