# HG changeset patch # User Kim Alvefur # Date 1601310960 -7200 # Node ID f23cf8e2e2ff9090b62014c84e5c24e97b76b3e7 # Parent dd1713862c204545351a58da8dba673a755643bf util.error: Cover registry initialization in test diff -r dd1713862c20 -r f23cf8e2e2ff spec/util_error_spec.lua --- a/spec/util_error_spec.lua Mon Sep 28 16:21:41 2020 +0100 +++ b/spec/util_error_spec.lua Mon Sep 28 18:36:00 2020 +0200 @@ -76,5 +76,25 @@ 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);