/
get_data.t
36 lines (27 loc) · 961 Bytes
/
get_data.t
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
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();
ok exists $data{'_source'}, '_source exists in hash';
is $data{'_source'}, $file, '_source is the file';
};
subtest 'ISBN_RANGE_MESSAGE does not exist' => sub {
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';
like $data{'_source'}, qr|lib/Business/ISBN/RangeMessage.xml\z|, '_source is distributed file';
};
done_testing();