Software /
code /
prosody
Comparison
spec/util_error_spec.lua @ 11092:bd13aa89262d
util.error: Collect Application-Specific Conditions from stanza errors
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Sep 2020 18:15:49 +0200 |
parent | 11089:35d2260644d9 |
child | 11097:f23cf8e2e2ff |
comparison
equal
deleted
inserted
replaced
11091:4b4b5188492f | 11092:bd13aa89262d |
---|---|
46 | 46 |
47 describe("from_stanza", function () | 47 describe("from_stanza", function () |
48 it("works", function () | 48 it("works", function () |
49 local st = require "util.stanza"; | 49 local st = require "util.stanza"; |
50 local m = st.message({ type = "chat" }); | 50 local m = st.message({ type = "chat" }); |
51 local e = st.error_reply(m, "modify", "bad-request", nil, "error.example"); | 51 local e = st.error_reply(m, "modify", "bad-request", nil, "error.example"):tag("extra", { xmlns = "xmpp:example.test" }); |
52 local err = errors.from_stanza(e); | 52 local err = errors.from_stanza(e); |
53 assert.truthy(errors.is_err(err)); | 53 assert.truthy(errors.is_err(err)); |
54 assert.equal("modify", err.type); | 54 assert.equal("modify", err.type); |
55 assert.equal("bad-request", err.condition); | 55 assert.equal("bad-request", err.condition); |
56 assert.equal(e, err.context.stanza); | 56 assert.equal(e, err.context.stanza); |
57 assert.equal("error.example", err.context.by); | 57 assert.equal("error.example", err.context.by); |
58 assert.not_nil(err.extra.tag); | |
58 end); | 59 end); |
59 end); | 60 end); |
60 | 61 |
61 describe("__tostring", function () | 62 describe("__tostring", function () |
62 it("doesn't throw", function () | 63 it("doesn't throw", function () |