]> git.ipfire.org Git - people/ms/libloc.git/blame - src/perl/t/Location.t
perl: Use absolute paths for opening database
[people/ms/libloc.git] / src / perl / t / Location.t
CommitLineData
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
8use strict;
9use warnings;
10
85aa96e3 11# Where to find the test database.
01e8fdce 12my $testdb = "$ENV{'srcdir'}/testdata/test.db";
85aa96e3
SS
13
14use Test::More tests => 5;
1ea740e9
SS
15BEGIN { 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.
23my $address = "2a07:1c44:5800::1";
24
25# Connect to the database.
26my $db = &Location::init("$testdb");
27
28my $vendor = &Location::get_vendor($db);
29ok($vendor eq "IPFire Project", "Test 1 - Get Database Vendor");
30
31my $license = &Location::get_license($db);
32ok($license eq "CC", "Test 2 - Get Database license");
33
34my $description = &Location::get_description($db);
35ok($description eq "This is a geo location database", "Test 3 - Get Database Description");
36
37my $country_code = &Location::lookup_country_code($db, $address);
38ok($country_code eq "DE", "Test 4 - Lookup country code for $address");