]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
config.basic: test coverage for parse_rdata()
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 25 Nov 2021 11:14:31 +0000 (12:14 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 25 Nov 2021 12:13:45 +0000 (13:13 +0100)
tests/config/basic.test.lua

index af9a5847c5d8ba0c73dd8d78dfd53f5d8498db71..73356a43dc2bf83ebb5305424938d852812faf49 100644 (file)
@@ -31,6 +31,15 @@ local function test_globals()
        same(table_print({fakepizza=1}), "{\n    ['fakepizza'] = 1,\n}", 'table print works on tables')
 end
 
+-- test global API functions
+local function test_global_functions()
+       boom(kres.parse_rdata, {'A 127.0.0.1'}, 'parse_rdata with non-table argument')
+       boom(kres.parse_rdata, {{1}}, 'parse_rdata with non-string data in arg table')
+       same(kres.parse_rdata({'A 127.0.0.1'}), {string.char(127, 0, 0, 1)}, 'parse_rdata with single record')
+       same(kres.parse_rdata({'A 127.0.0.1', 'A 127.0.0.2'}),
+               {string.char(127, 0, 0, 1), string.char(127, 0, 0, 2)}, 'parse_rdata with multiple records')
+end
+
 -- test if dns library functions work
 local function test_rrset_functions()
        local rr = {owner = '\3com\0', ttl = 1, type = kres.type.TXT, rdata = '\5hello'}
@@ -195,6 +204,7 @@ end
 return {
        test_constants,
        test_globals,
+       test_global_functions,
        test_rrset_functions,
        test_packet_functions,
        test_json_functions,