perl: Add tests to testsuite.

Message ID 20191001061554.4647-1-stefan.schantl@ipfire.org
State Accepted
Commit 85aa96e30f2b01412b98953168a0f6159af234bf
Headers
Series perl: Add tests to testsuite. |

Commit Message

Stefan Schantl Oct. 1, 2019, 6:15 a.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/perl/t/Location.t | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/perl/t/Location.t b/src/perl/t/Location.t
index a68c094..aef15c3 100644
--- a/src/perl/t/Location.t
+++ b/src/perl/t/Location.t
@@ -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");