From patchwork Tue Oct 1 06:15:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2446 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 46j8Ch1vzpz3yqH for ; Tue, 1 Oct 2019 06:16:00 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 46j8Cg71Ydz3JL; Tue, 1 Oct 2019 06:15:59 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 46j8Cg52M1z2ygP; Tue, 1 Oct 2019 06:15:59 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 46j8Cf4XmVz2yXw; Tue, 1 Oct 2019 06:15:58 +0000 (UTC) Received: from tuxedo.stevee (unknown [46.125.250.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 46j8Cf1MhZz2KC; Tue, 1 Oct 2019 06:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1569910558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+cyNEMUVjivPgh75eQXilgUxWOS1eJKKHvwZ3wezRZ0=; b=NZFjtssPn+HUPBnb/MX5LqbNjat1JuNsakoToGtuppFaB+x8HhmuBTq/cGbP3OTkBRGbH2 uBpFx1HjNn/5YB8LY7BZ1ec2Wy3voGZ3iVTBKRJUvlk8ama+3RItdXwujsxKaWXN3yhJcF zX7JJmzlT6GxVKZlkZxEjlNnY1UAGkj/p+937aalavFIZR2BGkSZI2VLrTQZwy1DCB4Wsx XbBxIbyDnUOpjtGaZ+3M3gIDKXmTKa0CugL97NGharagghRYakuehw/yvvUJDg3wiAOI2+ i4/6DXR+Jsr3EZZutM3MkvptXwTDVAXoPtWTNlkNe2zUGuVFbA4wVV/qUDTf6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1569910558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+cyNEMUVjivPgh75eQXilgUxWOS1eJKKHvwZ3wezRZ0=; b=rJ2abis8f5TBlFT9ofNEztLqmbmMQmpF5KtVsaEybbZkcf3AqN1457sCJlogb1j5Q5VTXd z46dIc1aEmepT5Ag== From: Stefan Schantl To: development@lists.ipfire.org, location@lists.ipfire.org Subject: [PATCH] perl: Add tests to testsuite. Date: Tue, 1 Oct 2019 08:15:54 +0200 Message-Id: <20191001061554.4647-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: location@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: location-bounces@lists.ipfire.org Sender: "Location" Signed-off-by: Stefan Schantl --- src/perl/t/Location.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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");