-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use Test::More; | ||
|
||
use File::Basename; | ||
|
||
my $class = 'Business::ISBN::Data'; | ||
use_ok $class; | ||
|
||
my @subs = qw( | ||
isbn_data_source | ||
); | ||
|
||
can_ok 'Business::ISBN', @subs; | ||
|
||
subtest 'source' => sub { | ||
ok exists $Business::ISBN::country_data{'_source'}, 'country_data has _source'; | ||
like $Business::ISBN::country_data{'_source'}, qr/RangeMessage\.xml/, 'source is RangeMessage'; | ||
is Business::ISBN::isbn_data_source(), $Business::ISBN::country_data{'_source'}, 'isbn_data_source returns _source'; | ||
|
||
delete local $Business::ISBN::country_data{'_source'}; | ||
unlike $Business::ISBN::country_data{'_source'}, qr/RangeMessage\.xml/, 'source is not RangeMessage'; | ||
is basename( Business::ISBN::isbn_data_source() ), 'Data.pm', 'source is module'; | ||
}; | ||
|
||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use Test::More; | ||
|
||
use File::Basename; | ||
|
||
my $class = 'Business::ISBN::Data'; | ||
use_ok $class; | ||
|
||
my @subs = qw( | ||
_parse_range_message | ||
); | ||
|
||
can_ok $class, @subs; | ||
|
||
subtest 'file does not exist' => sub { | ||
my $file = 'lib/Business/ISBN/RangeMessage.yamml'; | ||
ok ! -e $file, "$file does not exist"; | ||
|
||
diag( "This will be a warning here" ); | ||
my $result = Business::ISBN::Data::_parse_range_message( $file ); | ||
diag( "There should be no more warnings" ); | ||
ok ! defined $result, "_parse_range_message returns undef if file does not exist"; | ||
}; | ||
|
||
done_testing(); |