diff options
author | Matthew Wild <mwild1@gmail.com> | 2022-08-29 14:59:46 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2022-08-29 14:59:46 +0100 |
commit | b02ab508d51481e19991053645ed48dcb819c4d9 (patch) | |
tree | b6170b388a991545f78cad3ce3b1a730b784dd70 /spec/util_stanza_spec.lua | |
parent | a2cabe641854d887bd5814ddf3037a3c4cd7440d (diff) | |
download | prosody-b02ab508d51481e19991053645ed48dcb819c4d9.tar.gz prosody-b02ab508d51481e19991053645ed48dcb819c4d9.zip |
util.stanza: Add add_error() to simplify adding error tags to existing stanzas
Some fiddling is required now in error_reply() to ensure the cursor is in the
same place as before this change (a lot of code apparently uses that feature).
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r-- | spec/util_stanza_spec.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua index 8732a111..e11c70dd 100644 --- a/spec/util_stanza_spec.lua +++ b/spec/util_stanza_spec.lua @@ -314,6 +314,20 @@ describe("util.stanza", function() end) end) + describe("#add_error()", function () + describe("basics", function () + local s = st.stanza("custom", { xmlns = "urn:example:foo" }); + local e = s:add_error("cancel", "not-acceptable", "UNACCEPTABLE!!!! ONE MILLION YEARS DUNGEON!") + :tag("dungeon", { xmlns = "urn:uuid:c9026187-5b05-4e70-b265-c3b6338a7d0f", period="1000000years"}); + assert.equal(s, e); + local typ, cond, text, extra = e:get_error(); + assert.equal("cancel", typ); + assert.equal("not-acceptable", cond); + assert.equal("UNACCEPTABLE!!!! ONE MILLION YEARS DUNGEON!", text); + assert.is_nil(extra); + end) + end) + describe("should reject #invalid", function () local invalid_names = { ["empty string"] = "", ["characters"] = "<>"; |