File: default_data.t

package info (click to toggle)
libbusiness-isbn-data-perl 20251205.001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 500 kB
  • sloc: xml: 8,996; perl: 553; makefile: 8
file content (54 lines) | stat: -rwxr-xr-x 1,494 bytes parent folder | download | duplicates (3)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl

# If you run into an ISBN that you think is valid but this module
# says is invalid, put it here.
#
# Grab the latest RangeMessage.xml file and see if the distributed
# data is just out of date.
my @isbns_from_issues = qw(
	9782021183061
	);


use Test::More;

use Data::Dumper;
use File::Spec::Functions qw(catfile);

SKIP: {
	my $tests = @isbns_from_issues + 3;
	skip "Need Business::ISBN 3.006 to run this test", $tests unless eval {
		require Business::ISBN;
		# 3.005 fixed a major problem with 979 numbers and the data
		# structure changed.
		Business::ISBN->VERSION('3.006');
		};

	diag( "Business::ISBN is " . Business::ISBN->VERSION );

	my $file = catfile( qw(blib lib Business ISBN RangeMessage.xml) );
	my $out_of_the_way = $file . '.hidden';

	ok( rename($file => $out_of_the_way), 'Renamed file' ) unless $ENV{AUTOPKGTEST_TMP};

	subtest 'compile' => sub {
		my @modules = qw( Business::ISBN::Data );
		foreach my $module ( @modules ) {
			BAIL_OUT( "Could not load $module" ) unless eval{ use_ok( $module ) };
			}
		};

	local %Business::ISBN::country_data = Business::ISBN::Data::_get_data();
	like( $Business::ISBN::country_data{_source}, qr/\bData\.pm/, 'Data source is the default data structure' );

	subtest 'check_isbns' => sub {
		foreach my $isbn ( @isbns_from_issues ) {
			my $i = Business::ISBN->new( $isbn );
			ok( $i->is_valid, "<$isbn> is valid" );
			}
		};

	rename $out_of_the_way => $file unless $ENV{AUTOPKGTEST_TMP};
	}

done_testing();