]> git.ipfire.org Git - location/libloc.git/commitdiff
lua: Check if we can read the network's properties
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Feb 2024 14:45:19 +0000 (14:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Feb 2024 14:45:19 +0000 (14:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/lua/main.lua

index 5be48736cb4939073164ed65a051b9e5d83969b5..baf1f766a36c638b567ff54e7d580a7a79a03d75 100755 (executable)
@@ -43,7 +43,11 @@ function test_lookup()
        db = location.Database.open(ENV_TEST_DATABASE)
 
        -- Perform a lookup
-       db.lookup("81.3.27.32")
+       network = db:lookup("81.3.27.32")
+
+       luaunit.assertEquals(network:get_family(), 2) -- AF_INET
+       luaunit.assertEquals(network:get_country_code(), "DE")
+       luaunit.assertEquals(network:get_asn(), 24679)
 end
 
 function test_network()
@@ -55,7 +59,7 @@ function test_network()
        luaunit.assertNil(n1:get_asn())
 
        -- The family should be IPv4
-       luaunit.assertEquals(n1:get_family(), 2)
+       luaunit.assertEquals(n1:get_family(), 2) -- AF_INET
 
        -- The country code should be empty
        luaunit.assertNil(n1:get_country_code())