From dc446463ab10d466f5c67cab4530156a85d4dd9f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 28 Sep 2020 18:36:00 +0200 Subject: util.error: Cover registry initialization in test --- spec/util_error_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/util_error_spec.lua b/spec/util_error_spec.lua index bb85d303..6314d9ff 100644 --- a/spec/util_error_spec.lua +++ b/spec/util_error_spec.lua @@ -76,5 +76,25 @@ describe("util.error", function () end); end) + describe("init", function() + it("basics works", function() + local reg = errors.init("test", { + broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("}; + nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"}; + }); + + local broke = reg.new("broke"); + assert.equal("cancel", broke.type); + assert.equal("internal-server-error", broke.condition); + assert.equal("It broke :(", broke.text); + assert.equal("test", broke.source); + + local nope = reg.new("nope"); + assert.equal("auth", nope.type); + assert.equal("not-authorized", nope.condition); + assert.equal("Can't let you do that Dave", nope.text); + end); + end); + end); -- cgit v1.2.3