aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_error_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-09-28 18:39:51 +0200
committerKim Alvefur <zash@zash.se>2020-09-28 18:39:51 +0200
commite04db26e8fa4d0af71d79b6dbe2192917d38d379 (patch)
treed64c07f7c26700b2a07473d9ef1581da14384973 /spec/util_error_spec.lua
parent9d5d74ea0658d5d6ce7ea4360167c58eaa083a1f (diff)
downloadprosody-e04db26e8fa4d0af71d79b6dbe2192917d38d379.tar.gz
prosody-e04db26e8fa4d0af71d79b6dbe2192917d38d379.zip
util.error: Add a "compact mode" for registries
Inspired by the older registry in pubsub.lib.lua
Diffstat (limited to 'spec/util_error_spec.lua')
-rw-r--r--spec/util_error_spec.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/util_error_spec.lua b/spec/util_error_spec.lua
index 6314d9ff..399b5998 100644
--- a/spec/util_error_spec.lua
+++ b/spec/util_error_spec.lua
@@ -94,6 +94,27 @@ describe("util.error", function ()
assert.equal("not-authorized", nope.condition);
assert.equal("Can't let you do that Dave", nope.text);
end);
+
+ it("compact mode works", function()
+ local reg = errors.init("test", {
+ namespace = "spec";
+ broke = {"cancel"; "internal-server-error"; "It broke :("};
+ nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-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.is_nil(broke.extra);
+
+ 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);
+ assert.equal("spec", nope.extra.namespace);
+ assert.equal("sorry-dave", nope.extra.condition);
+ end);
end);
end);