Changeset

11097:f23cf8e2e2ff

util.error: Cover registry initialization in test
author Kim Alvefur <zash@zash.se>
date Mon, 28 Sep 2020 18:36:00 +0200
parents 11096:dd1713862c20
children 11098:5b778ec095f0
files spec/util_error_spec.lua
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/spec/util_error_spec.lua	Mon Sep 28 16:21:41 2020 +0100
+++ b/spec/util_error_spec.lua	Mon Sep 28 18:36:00 2020 +0200
@@ -76,5 +76,25 @@
 		end);
 	end)
 
+	describe("init", function()
+		it("basics works", function()
+			local reg = errors.init("test", {
+				broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("};
+				nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"};
+			});
+
+			local broke = reg.new("broke");
+			assert.equal("cancel", broke.type);
+			assert.equal("internal-server-error", broke.condition);
+			assert.equal("It broke :(", broke.text);
+			assert.equal("test", broke.source);
+
+			local nope = reg.new("nope");
+			assert.equal("auth", nope.type);
+			assert.equal("not-authorized", nope.condition);
+			assert.equal("Can't let you do that Dave", nope.text);
+		end);
+	end);
+
 end);