Software /
code /
prosody
Comparison
spec/util_error_spec.lua @ 11089:35d2260644d9
util.error: Extract error originator from stanza errors
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Sep 2020 18:13:27 +0200 |
parent | 11081:0b68697450c5 |
child | 11092:bd13aa89262d |
comparison
equal
deleted
inserted
replaced
11088:1f84d0e4d0c4 | 11089:35d2260644d9 |
---|---|
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"); | 51 local e = st.error_reply(m, "modify", "bad-request", nil, "error.example"); |
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 end); | 58 end); |
58 end); | 59 end); |
59 | 60 |
60 describe("__tostring", function () | 61 describe("__tostring", function () |
61 it("doesn't throw", function () | 62 it("doesn't throw", function () |