From 722eee9d03fb1933fed011a215b71b2c7603e442 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Tue, 17 Oct 2006 13:55:27 +0000 Subject: merge with upstream --- t/package.t | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 't') 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 ', 'get packager directly'); is($package->get_tag('packager'), 'Guillaume Rousse ', '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'); } -- cgit v1.2.1