Permalink
Browse files

Added test for failed lookup and magic 'A6' code

  • Loading branch information...
1 parent 4bde698 commit 360cc8136df52987a023f18ddbee074184a42b3e Cosimo Streppone committed Dec 20, 2011
Showing with 5 additions and 2 deletions.
  1. +3 −1 t/basic.t
  2. +2 −1 t/test.pm
View
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-#
+#
# Basic varnish-geoip tests
#
@@ -10,6 +10,8 @@ require test;
my @ip = (
[ '213.236.208.22' => 'NO' => 'Oslo' ],
[ '85.34.205.51' => 'IT' => 'Cividale Del Friuli' ],
+ # Test an undefined case. Country should be "A6"
+ [ '172.0.0.0' => 'A6' => '' ],
);
Test::More::plan(tests => 1 + (2 * @ip));
View
@@ -23,12 +23,13 @@ sub run_binary {
$cmd .= ' ';
$cmd .= join(' ', map { q(') . $_ . q(') } @args);
my $output = `$cmd`;
- return $output;
+ return $output;
}
sub get_bit {
my ($geoip_header, $bit_type) = @_;
my ($result) = ($geoip_header =~ m{$bit_type:([^,]*),});
+ $result = '' if not defined $result;
return $result;
}

0 comments on commit 360cc81

Please sign in to comment.