diff options
-rw-r--r-- | spec/util_error_spec.lua | 20 |
1 files changed, 20 insertions, 0 deletions
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); |