]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
perl: Add tests to testsuite.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 1 Oct 2019 06:15:54 +0000 (08:15 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Oct 2019 12:00:51 +0000 (12:00 +0000)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/perl/t/Location.t

index a68c094114479459a5180f3496815b74f886dade..aef15c3f4496e0e49dce0d13047e46236d5eca1d 100644 (file)
@@ -8,10 +8,31 @@
 use strict;
 use warnings;
 
-use Test::More tests => 1;
+# Where to find the test database.
+my $testdb = "../../testdata/test.db";
+
+use Test::More tests => 5;
 BEGIN { use_ok('Location') };
 
 #########################
 
 # Insert your test code below, the Test::More module is use()ed here so read
 # its man page ( perldoc Test::More ) for help writing this test script.
+
+# Address which should be used for database lookup.
+my $address = "2a07:1c44:5800::1";
+
+# Connect to the database.
+my $db = &Location::init("$testdb");
+
+my $vendor = &Location::get_vendor($db);
+ok($vendor eq "IPFire Project", "Test 1 - Get Database Vendor");
+
+my $license = &Location::get_license($db);
+ok($license eq "CC", "Test 2 - Get Database license");
+
+my $description = &Location::get_description($db);
+ok($description eq "This is a geo location database", "Test 3 - Get Database Description");
+
+my $country_code = &Location::lookup_country_code($db, $address);
+ok($country_code eq "DE", "Test 4 - Lookup country code for $address");