Comparison

spec/util_pubsub_spec.lua @ 9451:db82b096b842

util.pubsub tests: Ensure necessary tests run in the defined order
author Matthew Wild <mwild1@gmail.com>
date Mon, 01 Oct 2018 19:43:20 +0100
parent 9209:69e17edf8796
child 9516:038446c50630
comparison
equal deleted inserted replaced
9450:b890ceb1c24f 9451:db82b096b842
13 get subscriptions 13 get subscriptions
14 ]] 14 ]]
15 15
16 describe("util.pubsub", function () 16 describe("util.pubsub", function ()
17 describe("simple node creation and deletion", function () 17 describe("simple node creation and deletion", function ()
18 randomize(false); -- These tests are ordered
19
18 -- Roughly a port of scansion/scripts/pubsub_createdelete.scs 20 -- Roughly a port of scansion/scripts/pubsub_createdelete.scs
19 local service = pubsub.new(); 21 local service = pubsub.new();
20 22
21 describe("#create", function () 23 describe("#create", function ()
24 randomize(false); -- These tests are ordered
22 it("creates a new node", function () 25 it("creates a new node", function ()
23 assert.truthy(service:create("princely_musings", true)); 26 assert.truthy(service:create("princely_musings", true));
24 end); 27 end);
25 28
26 it("fails to create the same node again", function () 29 it("fails to create the same node again", function ()
27 assert.falsy(service:create("princely_musings", true)); 30 assert.falsy(service:create("princely_musings", true));
28 end); 31 end);
29 end); 32 end);
30 33
31 describe("#delete", function () 34 describe("#delete", function ()
35 randomize(false); -- These tests are ordered
32 it("deletes the node", function () 36 it("deletes the node", function ()
33 assert.truthy(service:delete("princely_musings", true)); 37 assert.truthy(service:delete("princely_musings", true));
34 end); 38 end);
35 39
36 it("can't delete an already deleted node", function () 40 it("can't delete an already deleted node", function ()
38 end); 42 end);
39 end); 43 end);
40 end); 44 end);
41 45
42 describe("simple publishing", function () 46 describe("simple publishing", function ()
47 randomize(false); -- These tests are ordered
48
43 local notified; 49 local notified;
44 local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212 50 local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212
45 notified = subscribers; 51 notified = subscribers;
46 end); 52 end);
47 local service = pubsub.new({ 53 local service = pubsub.new({
80 assert.is_nil(notified["someone"]); 86 assert.is_nil(notified["someone"]);
81 end); 87 end);
82 end); 88 end);
83 89
84 describe("#issue1082", function () 90 describe("#issue1082", function ()
91 randomize(false); -- These tests are ordered
92
85 local service = pubsub.new(); 93 local service = pubsub.new();
86 94
87 it("creates a node with max_items = 1", function () 95 it("creates a node with max_items = 1", function ()
88 assert.truthy(service:create("node", true, { max_items = 1 })); 96 assert.truthy(service:create("node", true, { max_items = 1 }));
89 end); 97 end);