From: Marek VavrusÌŒa Date: Fri, 24 Nov 2017 04:30:00 +0000 (-0800) Subject: tests/config: added basic assert support (compatible with busted) X-Git-Tag: v1.5.1~16^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14a0a181c8aba82c0f7c732727e4d49f8a7eec6b;p=thirdparty%2Fknot-resolver.git tests/config: added basic assert support (compatible with busted) There is no dependency on a testing library yet, so I added a basic interface for mocking and asserting test values to get something to start with. I'll probably replace it with busted or telescope later on to get nicer testing output. --- diff --git a/.luacheckrc b/.luacheckrc index 2e2f2775e..72f12770c 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -73,4 +73,5 @@ ignore = { files['daemon/lua'].ignore = {'111', '121', '122'} -- Tests and scripts can use global variables files['scripts'].ignore = {'111', '112', '113'} -files['tests'].ignore = {'111', '112', '113'} \ No newline at end of file +files['tests'].ignore = {'111', '112', '113'} +files['tests/config/test_utils.lua'].ignore = {'121'} \ No newline at end of file diff --git a/tests/config/test_utils.lua b/tests/config/test_utils.lua index b96a96788..33e81edbd 100644 --- a/tests/config/test_utils.lua +++ b/tests/config/test_utils.lua @@ -28,3 +28,24 @@ function contains(table, value) end return false end + +-- Emulate busted testing interface +local assert_builtin = assert +assert = setmetatable({}, { + __call = function (_, ...) + return assert_builtin(...) + end, + __index = { + truthy = function (expr) + assert_builtin(expr) + end, + falsy = function (expr) + assert_builtin(not expr) + end, + same = function (a, b) + if a ~= b then + assert_builtin(false, string.format('expected: %s got: %s', a, b)) + end + end, + } +}) \ No newline at end of file