[2/2] perl: Testsuite: Add tests for invalid address and address not in the database.

Message ID 20191002170753.6738-2-stefan.schantl@ipfire.org
State Accepted
Commit 946f433041a60fbcc537a6ebba1a2a96b8ae4394
Headers
Series [1/2] perl: Fix lookup if given address is invalid or not in DB. |

Commit Message

Stefan Schantl Oct. 2, 2019, 5:07 p.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/perl/t/Location.t | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/src/perl/t/Location.t b/src/perl/t/Location.t
index b583af4..55a18f3 100644
--- a/src/perl/t/Location.t
+++ b/src/perl/t/Location.t
@@ -36,3 +36,9 @@  ok($description eq "This is a geo location database", "Test 3 - Get Database Des
 
 my $country_code = &Location::lookup_country_code($db, $address);
 ok($country_code eq "DE", "Test 4 - Lookup country code for $address");
+
+$country_code = &Location::lookup_country_code($db, "1.1.1.1");
+if(defined($country_code)) { fail("Test 5 - Lookup country code for address not in Database."); }
+
+$country_code = &Location::lookup_country_code($db, "a.b.c.d");
+if(defined($country_code)) { fail("Test 6 - Lookup country code for invalid address.") }