Comparison

spec/util_error_spec.lua @ 11097:f23cf8e2e2ff

util.error: Cover registry initialization in test
author Kim Alvefur <zash@zash.se>
date Mon, 28 Sep 2020 18:36:00 +0200
parent 11092:bd13aa89262d
child 11100:3aa06cdd2dc8
comparison
equal deleted inserted replaced
11096:dd1713862c20 11097:f23cf8e2e2ff
74 assert.is_table(err.extra); 74 assert.is_table(err.extra);
75 assert.equal("file:///dev/null", err.extra.uri); 75 assert.equal("file:///dev/null", err.extra.uri);
76 end); 76 end);
77 end) 77 end)
78 78
79 describe("init", function()
80 it("basics works", function()
81 local reg = errors.init("test", {
82 broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("};
83 nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"};
84 });
85
86 local broke = reg.new("broke");
87 assert.equal("cancel", broke.type);
88 assert.equal("internal-server-error", broke.condition);
89 assert.equal("It broke :(", broke.text);
90 assert.equal("test", broke.source);
91
92 local nope = reg.new("nope");
93 assert.equal("auth", nope.type);
94 assert.equal("not-authorized", nope.condition);
95 assert.equal("Can't let you do that Dave", nope.text);
96 end);
97 end);
98
79 end); 99 end);
80 100