]>
Commit | Line | Data |
---|---|---|
1ea740e9 SS |
1 | # Before 'make install' is performed this script should be runnable with |
2 | # 'make test'. After 'make install' it should work as 'perl Location.t' | |
3 | ||
4 | ######################### | |
5 | ||
6 | # change 'tests => 1' to 'tests => last_test_to_print'; | |
7 | ||
8 | use strict; | |
9 | use warnings; | |
10 | ||
85aa96e3 | 11 | # Where to find the test database. |
01e8fdce | 12 | my $testdb = "$ENV{'srcdir'}/testdata/test.db"; |
85aa96e3 SS |
13 | |
14 | use Test::More tests => 5; | |
1ea740e9 SS |
15 | BEGIN { use_ok('Location') }; |
16 | ||
17 | ######################### | |
18 | ||
19 | # Insert your test code below, the Test::More module is use()ed here so read | |
20 | # its man page ( perldoc Test::More ) for help writing this test script. | |
85aa96e3 SS |
21 | |
22 | # Address which should be used for database lookup. | |
23 | my $address = "2a07:1c44:5800::1"; | |
24 | ||
25 | # Connect to the database. | |
26 | my $db = &Location::init("$testdb"); | |
27 | ||
28 | my $vendor = &Location::get_vendor($db); | |
29 | ok($vendor eq "IPFire Project", "Test 1 - Get Database Vendor"); | |
30 | ||
31 | my $license = &Location::get_license($db); | |
32 | ok($license eq "CC", "Test 2 - Get Database license"); | |
33 | ||
34 | my $description = &Location::get_description($db); | |
35 | ok($description eq "This is a geo location database", "Test 3 - Get Database Description"); | |
36 | ||
37 | my $country_code = &Location::lookup_country_code($db, $address); | |
38 | ok($country_code eq "DE", "Test 4 - Lookup country code for $address"); |