0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

adding integration tests

This commit is contained in:
Alex Kocharin 2013-12-30 12:25:26 +04:00
parent 5422de642e
commit 5d19b66290
4 changed files with 83 additions and 0 deletions

8
test/README.md Normal file
View file

@ -0,0 +1,8 @@
All tests are split in three folders:
- `unit` - Tests that cover functions that transform data in an non-trivial way. These tests simply require() a few files and run code in there, so they are very fast.
- `functional` - Tests that launch sinopia instance and perform a series of requests to it over http. They are slower than unit tests.
- `integration` - Tests that launch sinopia instance and do requests to it using npm. They are really slow and can hit a real npm registry.
Unit and functional tests are executed automatically with `yapm test`. Integration tests are supposed to be executed manually from time to time.

View file

@ -0,0 +1,25 @@
storage: ./.sinopia_test_env/test-storage
users:
test:
password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
uplinks:
npmjs:
url: https://registry.npmjs.org/
logs:
- {type: stdout, format: pretty, level: trace}
packages:
jju:
allow_access: all
allow_publish: all
proxy_access: npmjs
'*':
allow_access: all
allow_publish: all
listen: 55501

Binary file not shown.

50
test/integration/test.pl Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/perl
# note to readers: in perl it's useful, in javascript it isn't
use strict;
# setting up working environment && chdir there
use Cwd 'abs_path';
use File::Basename;
$ENV{HOME} = dirname(abs_path( __FILE__ )) . '/.sinopia_test_env';
system('rm -rf .sinopia_test_env ; mkdir .sinopia_test_env') and quit('fail');
chdir $ENV{HOME};
use Data::Dumper;
my $pid;
sub quit {
print $_[0]."\n";
exec("kill $pid ; exit 1");
}
# run sinopia in a child process
if (($pid = fork()) == 0) {
exec "../../../bin/sinopia ../config.yaml";
die "exec failed";
}
system('mkdir node_modules') and quit('fail');
system('npm set sinopia_test_config 12345') and quit('fail');
if (`cat .npmrc` !~ /sinopia_test_config/) {
quit "npm is using wrong config";
}
system('npm set registry http://localhost:55501') and quit('fail');
system(q{/bin/echo -e 'test\ntest\ns@s.s\n' | npm adduser}) and quit('fail');
system('npm install jju') and quit('fail');
(`node -e 'console.log(require("jju").parse("{qwerty:123}").qwerty+456)'` =~ /579/) or quit('fail');
system('npm publish ../sinopia-test-1.2.3.tgz') and quit('fail');
system('npm tag sinopia-test@1.2.3 meow') and quit('fail');
system('npm install sinopia-test@meow') and quit('fail');
(`node -e 'require("sinopia-test")'` =~ /w==w/) or quit('fail');
quit("
==================================================================
All tests seem to be executed successfully, nothing is broken yet.
==================================================================");