diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Makefile.am | 8 | ||||
-rw-r--r-- | t/gpghome/pubring.gpg | bin | 0 -> 565 bytes | |||
-rw-r--r-- | t/gpghome/random_seed | bin | 0 -> 600 bytes | |||
-rw-r--r-- | t/gpghome/secring.gpg | bin | 0 -> 628 bytes | |||
-rw-r--r-- | t/gpghome/trustdb.gpg | bin | 0 -> 1280 bytes | |||
-rwxr-xr-x | t/install.t | 51 | ||||
-rwxr-xr-x | t/perlcritic.t | 32 | ||||
-rwxr-xr-x | t/set.t | 124 | ||||
-rwxr-xr-x | t/sign.t | 57 | ||||
-rwxr-xr-x | t/tags.t | 55 |
10 files changed, 327 insertions, 0 deletions
diff --git a/t/Makefile.am b/t/Makefile.am new file mode 100644 index 0000000..0fd009c --- /dev/null +++ b/t/Makefile.am @@ -0,0 +1,8 @@ +TESTS = perlcritic.t \ + install.t \ + sign.t \ + tags.t + +TESTS_ENVIRONMENT = perl -I $(top_srcdir)/lib + +EXTRA_DIST = $(TESTS) gpghome diff --git a/t/gpghome/pubring.gpg b/t/gpghome/pubring.gpg Binary files differnew file mode 100644 index 0000000..fcfc0e3 --- /dev/null +++ b/t/gpghome/pubring.gpg diff --git a/t/gpghome/random_seed b/t/gpghome/random_seed Binary files differnew file mode 100644 index 0000000..1b0201e --- /dev/null +++ b/t/gpghome/random_seed diff --git a/t/gpghome/secring.gpg b/t/gpghome/secring.gpg Binary files differnew file mode 100644 index 0000000..9017e4d --- /dev/null +++ b/t/gpghome/secring.gpg diff --git a/t/gpghome/trustdb.gpg b/t/gpghome/trustdb.gpg Binary files differnew file mode 100644 index 0000000..30712a3 --- /dev/null +++ b/t/gpghome/trustdb.gpg diff --git a/t/install.t b/t/install.t new file mode 100755 index 0000000..69113ff --- /dev/null +++ b/t/install.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# $Id: install.t 1426 2006-12-17 21:00:25Z guillomovitch $ + +use Test::More tests => 3; +use Test::Exception; +use Youri::Repository::Test; +use Youri::Package::RPM::Generator; +use Youri::Package::RPM::URPM; +use Youri::Submit::Action::Install; + +my $writable_repository = Youri::Repository::Test->new(perms => '755'); +my $unwritable_repository = Youri::Repository::Test->new(perms => '000'); + +my $action = Youri::Submit::Action::Install->new( + skip => [ 'cheater' ] +); + +dies_ok { + $action->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new()->get_source(), + ), + $unwritable_repository, + undef, + undef + ) +} 'installing in a non-writable directory'; + +lives_ok { + $action->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new(tags => { + name => 'cheater', + })->get_source(), + ), + $unwritable_repository, + undef, + undef + ) +} 'installing in a non-writable directory with an exception'; + +lives_ok { + $action->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new()->get_source(), + ), + $writable_repository, + undef, + undef + ) +} 'installing in a writable directory'; diff --git a/t/perlcritic.t b/t/perlcritic.t new file mode 100755 index 0000000..e929713 --- /dev/null +++ b/t/perlcritic.t @@ -0,0 +1,32 @@ +#!/usr/bin/perl +# $Id: perlcritic.t 1530 2007-03-08 20:42:13Z guillomovitch $ + +use strict; +use warnings; +use Test::More; +use File::Basename; +use File::Spec; + +if (!$ENV{TEST_AUTHOR}) { + plan( + skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.' + ); +} + +eval { + require Test::Perl::Critic; +}; + +if ($@) { + plan( + skip_all => 'Test::Perl::Critic not installed, skipping' + ); +} + +Test::Perl::Critic->import(); +my $libdir = File::Spec->catdir( + dirname($0), + File::Spec->updir(), + 'lib' +); +all_critic_ok($libdir); @@ -0,0 +1,124 @@ +#!/usr/bin/perl +# $Id: /local/youri/soft/submit/trunk/t/tags.t 3062 2007-06-28T16:21:35.624871Z guillaume $ + +use Test::More tests => 7; +use Test::Exception; +use Youri::Package::RPM::Test; +use Youri::Submit::Test::Set; + +my $test = Youri::Submit::Test::Set->new( + skip => [ 'bar' ] +); + +lives_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'noarch' + }), + Youri::Package::RPM::Test->new(tags => { + arch => 'src', + }) + ] + ) +} 'one source and one binary package from the same source succeed'; + +throws_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'src' + }), + Youri::Package::RPM::Test->new(tags => { + arch => 'noarch', + sourcerpm => 'other-1-1.src.rpm', + }) + ] + ) +} qr/not a canonical package set/, +'one source and one binary packages from different sources fails'; + +throws_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'noarch' + }) + ] + ) +} qr/number of source packages < 1/, +'just one source binary fails'; + +throws_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'src' + }) + ] + ) +} qr/number of binary packages < 1/, +'just one source binary fails'; + +throws_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'src' + }), + Youri::Package::RPM::Test->new(tags => { + arch => 'src' + }), + ] + ) +} qr/number of source packages > 1/, +'two source packages fails'; + +lives_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + arch => 'src' + }), + Youri::Package::RPM::Test->new(tags => { + arch => 'noarch' + }), + Youri::Package::RPM::Test->new(tags => { + arch => 'noarch' + }) + ] + ) +} +'one source and two binary packages succedd'; + +lives_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + name => 'bar', + release => '1mdk' + }) + ] + ) +} 'non-compliant package with exception succeed'; diff --git a/t/sign.t b/t/sign.t new file mode 100755 index 0000000..db6f619 --- /dev/null +++ b/t/sign.t @@ -0,0 +1,57 @@ +#!/usr/bin/perl +# $Id: sign.t 1407 2006-12-03 12:02:02Z guillomovitch $ + +use Test::More tests => 3; +use Test::Exception; +use File::Basename; +use Youri::Package::RPM::Generator; +use Youri::Package::RPM::URPM; +use Youri::Submit::Action::Sign; + +my $action1 = Youri::Submit::Action::Sign->new( + name => 'Youri', + path => dirname($0) . '/gpghome', + passphrase => 'Youri sux', + skip => [ 'cheater' ] +); + +dies_ok { + $action1->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new()->get_source(), + ), + undef, + undef, + undef + ) +} 'signing with wrong key'; + +lives_ok { + $action1->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new(tags => { + name => 'cheater', + })->get_source(), + ), + undef, + undef, + undef + ) +} 'signing with wrong key using an exception'; + +my $action2 = Youri::Submit::Action::Sign->new( + name => 'Youri', + path => dirname($0) . '/gpghome', + passphrase => 'Youri rulez', +); + +lives_ok { + $action2->run( + Youri::Package::RPM::URPM->new( + file => Youri::Package::RPM::Generator->new()->get_source(), + ), + undef, + undef, + undef + ) +} 'signing with correct key'; diff --git a/t/tags.t b/t/tags.t new file mode 100755 index 0000000..4946799 --- /dev/null +++ b/t/tags.t @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# $Id: tags.t 1687 2007-06-28 22:44:07Z guillomovitch $ + +use Test::More tests => 3; +use Test::Exception; +use Youri::Package::RPM::Test; +use Youri::Submit::Test::Tag; + +my $test = Youri::Submit::Test::Tag->new( + tags => { release => 'plf$' }, + skip => [ 'bar' ] +); + +lives_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + name => 'foo', + release => '1plf' + }) + ] + ) +} 'compliant package succeed'; + +throws_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + name => 'foo', + release => '1mdk' + }) + ] + ) +} qr/invalid value 1mdk for tag release/, +'non-compliant package fails'; + +lives_ok { + $test->run( + undef, + undef, + undef, + [ + Youri::Package::RPM::Test->new(tags => { + name => 'bar', + release => '1mdk' + }) + ], + ) +} 'non-compliant package with exception succeed'; |