aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/package.t39
1 files changed, 19 insertions, 20 deletions
diff --git a/t/package.t b/t/package.t
index 6a6d4b2..25e7798 100755
--- a/t/package.t
+++ b/t/package.t
@@ -5,22 +5,27 @@ use Test::More;
use Test::Exception;
use Youri::Utils;
use File::Temp qw/tempdir/;
+use File::Basename;
use strict;
my @classes = qw/
Youri::Package::URPM
Youri::Package::RPM4
/;
-my $file = 't/cowsay-3.03-11mdv2007.0.noarch.rpm';
-my $fake_file = 'foobar.rpm';
-plan(tests => 36 * scalar @classes);
+my $dir = dirname($0);
+my $rpm = 'cowsay-3.03-11mdv2007.0.noarch.rpm';
+my $fake_rpm = 'foobar.rpm';
+plan(tests => 37 * scalar @classes);
foreach my $class (@classes) {
- load($class);
+ load_class($class);
+
+ my $temp_dir = tempdir(CLEANUP => 1);
+ my $file = "$dir/$rpm";
+ my $fake_file = "$temp_dir/$fake_rpm";
# instanciation errors
dies_ok { $class->new(file => undef) } 'undefined file';
- unlink $fake_file;
dies_ok { $class->new(file => $fake_file) } 'non-existant file';
system('touch', $fake_file);
chmod 0000, $fake_file;
@@ -46,11 +51,12 @@ foreach my $class (@classes) {
is($package->get_tag('url'), 'http://www.nog.net/~tony/warez/cowsay.shtml', 'get url indirectly');
is($package->get_packager(), 'Guillaume Rousse <guillomovitch@mandriva.org>', 'get packager directly');
is($package->get_tag('packager'), 'Guillaume Rousse <guillomovitch@mandriva.org>', 'get packager indirectly');
+ is($package->get_file_name(), 'cowsay-3.03-11mdv2007.0.noarch.rpm', 'file name');
+ is($package->get_revision(), '3.03-11mdv2007.0', 'revision');
# name formating
- is($package->get_revision_name(), 'cowsay-3.03-11mdv2007.0', 'revision name');
- is($package->get_full_name(), 'cowsay-3.03-11mdv2007.0.noarch', 'full name');
- is($package->get_file_name(), 'cowsay-3.03-11mdv2007.0.noarch.rpm', 'file name');
+ is($package->as_formated_string('%{name}-%{version}-%{release}'), 'cowsay-3.03-11mdv2007.0', 'formated string name');
+ is($package->as_string(), 'cowsay-3.03-11mdv2007.0.noarch', 'default string');
is($package, 'cowsay-3.03-11mdv2007.0.noarch', 'stringification');
# type
@@ -478,20 +484,13 @@ foreach my $class (@classes) {
'last change'
);
is($package->compare($package), 0, 'compare');
-}
-
-foreach my $class (@classes) {
- load($class);
-
- my $tempdir = tempdir(CLEANUP => 1);
- system('cp', $file, $tempdir);
- my $package = $class->new(file => "$tempdir/cowsay-3.03-11mdv2007.0.noarch.rpm");
+ # signature test
+ system('cp', $file, $temp_dir);
+ $package = $class->new(file => "$temp_dir/$rpm");
$package->sign('Youri', 't/gpghome', 'Youri rulez');
- my $resigned_package = $class->new(file => "$tempdir/cowsay-3.03-11mdv2007.0.noarch.rpm");
- is($resigned_package->get_gpg_key(), '2333e817', 'get gpg key');
-
- system('rm', '-fr', '--', $tempdir);
+ $package = $class->new(file => "$temp_dir/$rpm");
+ is($package->get_gpg_key(), '2333e817', 'get gpg key');
}