Skip to content

Commit

Permalink
test GeoIP
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Sep 25, 2013
1 parent d614a6e commit 9ac9143
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
*.swp
.build/
data/
17 changes: 16 additions & 1 deletion t/01-adserver.t
Expand Up @@ -4,7 +4,7 @@ use warnings;
use Test::More;
use Test::Deep qw(cmp_details);

plan tests => 7;
plan tests => 8;

use WWW::AdServer;
use WWW::AdServer::Database;
Expand Down Expand Up @@ -64,6 +64,20 @@ subtest 'IL' => sub {
one_deeply_ok($ads->[0], $il_ads, 'one IL shuffle');
};

subtest 'geoip' => sub {
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
my %data = (
'24.24.24.24' => 'US',
'86.59.162.2' => 'HU',
);
foreach my $ip (sort keys %data) {
my $country = $gi->country_code_by_addr($ip);
#diag $country;
is($country, $data{$ip}, $ip);
}
};

sub one_deeply_ok {
my ($real, $possibilities, $name) = @_;
$name ||= '';
Expand All @@ -78,3 +92,4 @@ sub one_deeply_ok {
}



0 comments on commit 9ac9143

Please sign in to comment.