From 14a0a181c8aba82c0f7c732727e4d49f8a7eec6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Vavrus=CC=8Ca?= Date: Thu, 23 Nov 2017 20:30:00 -0800 Subject: [PATCH] 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. --- .luacheckrc | 3 ++- tests/config/test_utils.lua | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) 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 -- 2.47.2