perl: Testsuite: Add test for lookup_asn()
Commit Message
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
src/perl/t/Location.t | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hi,
> On 1 Oct 2019, at 07:24, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
>
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> src/perl/t/Location.t | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/perl/t/Location.t b/src/perl/t/Location.t
> index aef15c3..af5e258 100644
> --- a/src/perl/t/Location.t
> +++ b/src/perl/t/Location.t
> @@ -11,7 +11,7 @@ use warnings;
> # Where to find the test database.
> my $testdb = "../../testdata/test.db";
>
> -use Test::More tests => 5;
> +use Test::More tests => 6;
> BEGIN { use_ok('Location') };
>
> #########################
> @@ -36,3 +36,6 @@ 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");
> +
> +my $as_number = &Location::lookup_asn($db, $address);
> +ok($as_number eq "204867", "Test 5 - Lookup Autonomous System for $address”);
You should also test functions like this for invalid inputs and check if you get the correct response.
That would be two things here:
1) An invalid IP address like (a.b.c.d)
2) A valid IP address, but which is not in the database
You can submit that as an extra patch.
-Michael
> --
> 2.20.1
>
@@ -11,7 +11,7 @@ use warnings;
# Where to find the test database.
my $testdb = "../../testdata/test.db";
-use Test::More tests => 5;
+use Test::More tests => 6;
BEGIN { use_ok('Location') };
#########################
@@ -36,3 +36,6 @@ 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");
+
+my $as_number = &Location::lookup_asn($db, $address);
+ok($as_number eq "204867", "Test 5 - Lookup Autonomous System for $address");