util_pubsub_spec: Beginnings of tests for util.pubsub
authorKim Alvefur <zash@zash.se>
Sat, 03 Mar 2018 20:55:46 +0100
changeset 8561 5de663cef508
parent 8560 28f9b8a5d9cb
child 8564 7b9ffddc4276
util_pubsub_spec: Beginnings of tests for util.pubsub
spec/util_pubsub_spec.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spec/util_pubsub_spec.lua	Sat Mar 03 20:55:46 2018 +0100
@@ -0,0 +1,27 @@
+local pubsub = require "util.pubsub";
+describe("util.pubsub", function ()
+	describe("simple node creation and deletion", function ()
+		-- Roughly a port of scansion/scripts/pubsub_createdelete.scs
+		local service = pubsub.new();
+
+		describe("#create", function ()
+			it("creates a new node", function ()
+				assert.truthy(service:create("princely_musings", true));
+			end);
+
+			it("fails to create the same node again", function ()
+				assert.falsy(service:create("princely_musings", true));
+			end);
+		end);
+
+		describe("#delete", function ()
+			it("deletes the node", function ()
+				assert.truthy(service:delete("princely_musings", true));
+			end);
+
+			it("can't delete an already deleted node", function ()
+				assert.falsy(service:delete("princely_musings", true));
+			end);
+		end);
+	end);
+end);