1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
use Test::More;
use File::Basename;
my $class = 'Business::ISBN::Data';
use_ok $class;
my @subs = qw(
_get_data
);
can_ok $class, @subs;
subtest 'ISBN_RANGE_MESSAGE exists' => sub {
my $file = 'lib/Business/ISBN/RangeMessage.xml';
ok -e $file, "$file exists";
local $ENV{ISBN_RANGE_MESSAGE} = $file;
my %data = Business::ISBN::Data->_get_data();
SKIP: {
skip "No RangeMessage.xml in installed package", 1 if $ENV{AUTOPKGTEST_TMP};
}
ok exists $data{'_source'}, '_source exists in hash';
is $data{'_source'}, $file, '_source is the file';
};
subtest 'ISBN_RANGE_MESSAGE does not exist' => sub {
plan skip_all => "Debian doesn't include a RangeMessage.xml that could be tested here" if $ENV{AUTOPKGTEST_TMP};
my $file = 'lib/Business/ISBN/RangeMessage.yaml';
ok ! -e $file, "$file does not exist";
local $ENV{ISBN_RANGE_MESSAGE} = $file;
diag( "This will be a warning here" );
my %data = Business::ISBN::Data->_get_data();
diag( "There should be no more warnings" );
ok exists $data{'_source'}, '_source exists in hash';
is basename($data{'_source'}), 'RangeMessage.xml', '_source is distributed file';
};
done_testing();
|