Better (i.e. more) tests

This commit is contained in:
Dave Cross 2017-07-12 16:18:19 +01:00
parent c3d4d89430
commit 41dbc92154
2 changed files with 23 additions and 10 deletions

0
t/empty.spec Normal file
View file

View file

@ -1,16 +1,29 @@
use Test::More tests => 11;
use Test::More;
use Test::Exception;
BEGIN { use_ok('Parse::RPM::Spec') };
ok($spec = Parse::RPM::Spec->new( { file => 't/file.spec' } ));
ok($spec = Parse::RPM::Spec->new( { file => 't/file.spec' } ),
'Got an object');
isa_ok($spec, 'Parse::RPM::Spec');
is($spec->name, 'perl-Array-Compare');
is($spec->summary, 'Perl extension for comparing arrays');
is($spec->epoch, 1);
is($spec->name, 'perl-Array-Compare', 'Correct name');
is($spec->summary, 'Perl extension for comparing arrays', 'Correct summary');
is($spec->epoch, 1, 'Correct epoch');
is($spec->version, '1.16');
is($spec->version, '1.16', 'Correct version');
$spec->version('1.17');
is($spec->version, '1.17');
is($spec->buildarch, 'noarch');
is(@{$spec->buildrequires}, 2);
is($spec->buildrequires->[0], 'perl >= 1:5.6.0');
is($spec->version, '1.17', 'Changed version correctly');
is($spec->buildarch, 'noarch', 'Correct build arrchitecture');
is(@{$spec->buildrequires}, 2, 'Correct number of build requirements');
is($spec->buildrequires->[0], 'perl >= 1:5.6.0',
'First build requirement is correct');
dies_ok { Parse::RPM::Spec->new }
'No spec file given';
dies_ok { Parse::RPM::Spec->new( file => 'not-there') }
'Missing spec file given';
dies_ok { Parse::RPM::Spec->new( file => 'empty.spec') }
'Empty spec file given';
done_testing;