aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_stanza_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-12-14 22:47:41 +0100
committerKim Alvefur <zash@zash.se>2019-12-14 22:47:41 +0100
commit4e34c40ece0eb19f85720d63b1b0372f59e5616d (patch)
treee593facca294a596630c76644be654e8d02f56de /spec/util_stanza_spec.lua
parent71d99b65fa50afebb0241199d4000a8a7c50e1d1 (diff)
downloadprosody-4e34c40ece0eb19f85720d63b1b0372f59e5616d.tar.gz
prosody-4e34c40ece0eb19f85720d63b1b0372f59e5616d.zip
util.stanza: Accept util.error object to error_reply
If we're moving towards util.error as the standard error container then this makes sense. This may allow for future extensibility without needing a lot of optional arguments.
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r--spec/util_stanza_spec.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua
index b754f59d..d38a609f 100644
--- a/spec/util_stanza_spec.lua
+++ b/spec/util_stanza_spec.lua
@@ -1,5 +1,6 @@
local st = require "util.stanza";
+local errors = require "util.error";
describe("util.stanza", function()
describe("#preserialize()", function()
@@ -231,6 +232,22 @@ describe("util.stanza", function()
end, "got stanza of type error");
end);
+ it("should accept util.error objects", function ()
+ local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello");
+ local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork" });
+ local r = st.error_reply(s, e);
+
+ assert.are.equal(r.name, s.name);
+ assert.are.equal(r.id, s.id);
+ assert.are.equal(r.attr.to, s.attr.from);
+ assert.are.equal(r.attr.from, s.attr.to);
+ assert.are.equal(r.attr.type, "error");
+ assert.are.equal(r.tags[1].name, "error");
+ assert.are.equal(r.tags[1].attr.type, e.type);
+ assert.are.equal(r.tags[1].tags[1].name, e.condition);
+ assert.are.equal(r.tags[1].tags[2]:get_text(), e.text);
+ end);
+
end);
describe("should reject #invalid", function ()