aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_error_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-09-28 22:13:04 +0200
committerKim Alvefur <zash@zash.se>2020-09-28 22:13:04 +0200
commit9dbdb91c471ea765936a15af02b62e4cbf7ba7a2 (patch)
tree2806b577fda520041b785e11a2b95d4b13c9037e /spec/util_error_spec.lua
parent5da983d8bdc574f9358a16eb08d700dde3ca7026 (diff)
downloadprosody-9dbdb91c471ea765936a15af02b62e4cbf7ba7a2.tar.gz
prosody-9dbdb91c471ea765936a15af02b62e4cbf7ba7a2.zip
util.error: Expand compact registries into normal form internally
Also the exposed form on the table returned from init()
Diffstat (limited to 'spec/util_error_spec.lua')
-rw-r--r--spec/util_error_spec.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/util_error_spec.lua b/spec/util_error_spec.lua
index 399b5998..8b995895 100644
--- a/spec/util_error_spec.lua
+++ b/spec/util_error_spec.lua
@@ -115,6 +115,38 @@ describe("util.error", function ()
assert.equal("spec", nope.extra.namespace);
assert.equal("sorry-dave", nope.extra.condition);
end);
+
+ it("registry looks the same regardless of syntax", function()
+ local normal = 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";
+ extra = {namespace = "spec"; condition = "sorry-dave"};
+ };
+ });
+ local compact1 = 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 compact2 = errors.init("test", "spec", {
+ broke = {"cancel"; "internal-server-error"; "It broke :("};
+ nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"};
+ });
+ local compact3 = errors.init("test", {
+ broke = {"cancel"; "internal-server-error"; "It broke :("};
+ nope = {"auth"; "not-authorized"; "Can't let you do that Dave"};
+ });
+ assert.same(normal.registry, compact1.registry);
+ assert.same(normal.registry, compact2.registry);
+
+ assert.same({
+ broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("};
+ nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"};
+ }, compact3.registry);
+ end);
end);
end);