Software /
code /
prosody
Annotate
spec/util_pubsub_spec.lua @ 9174:160032d55ff1
util.pubsub tests: Add initial node config tests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 12 Aug 2018 11:34:28 +0100 |
parent | 9173:c53663e13b51 |
child | 9175:43b6f67aba05 |
rev | line source |
---|---|
8564
fd41dc4a78e9
util_pubsub_spec: Move util.pubsub import into a setup block
Kim Alvefur <zash@zash.se>
parents:
8558
diff
changeset
|
1 local pubsub; |
fd41dc4a78e9
util_pubsub_spec: Move util.pubsub import into a setup block
Kim Alvefur <zash@zash.se>
parents:
8558
diff
changeset
|
2 setup(function () |
fd41dc4a78e9
util_pubsub_spec: Move util.pubsub import into a setup block
Kim Alvefur <zash@zash.se>
parents:
8558
diff
changeset
|
3 pubsub = require "util.pubsub"; |
fd41dc4a78e9
util_pubsub_spec: Move util.pubsub import into a setup block
Kim Alvefur <zash@zash.se>
parents:
8558
diff
changeset
|
4 end); |
fd41dc4a78e9
util_pubsub_spec: Move util.pubsub import into a setup block
Kim Alvefur <zash@zash.se>
parents:
8558
diff
changeset
|
5 |
8558
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 describe("util.pubsub", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 describe("simple node creation and deletion", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 -- Roughly a port of scansion/scripts/pubsub_createdelete.scs |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 local service = pubsub.new(); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 describe("#create", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 it("creates a new node", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 assert.truthy(service:create("princely_musings", true)); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 it("fails to create the same node again", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 assert.falsy(service:create("princely_musings", true)); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 describe("#delete", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 it("deletes the node", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 assert.truthy(service:delete("princely_musings", true)); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 it("can't delete an already deleted node", function () |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 assert.falsy(service:delete("princely_musings", true)); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end); |
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 end); |
8647
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
31 |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
32 describe("simple publishing", function () |
9173
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
33 local notified; |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
34 local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
35 notified = subscribers; |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
36 end); |
8817
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
37 local service = pubsub.new({ |
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
38 broadcaster = broadcaster; |
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
39 }); |
8647
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
40 |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
41 it("creates a node", function () |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
42 assert.truthy(service:create("node", true)); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
43 end); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
44 |
8817
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
45 it("lets someone subscribe", function () |
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
46 assert.truthy(service:add_subscription("node", true, "someone")); |
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
47 end); |
9a3066a580ad
spec/util_pubsub: Test whether someone can subscribe to a node
Kim Alvefur <zash@zash.se>
parents:
8647
diff
changeset
|
48 |
8647
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
49 it("publishes an item", function () |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
50 assert.truthy(service:publish("node", true, "1", "item 1")); |
9173
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
51 assert.truthy(notified["someone"]); |
8647
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
52 end); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
53 |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
54 it("called the broadcaster", function () |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
55 assert.spy(broadcaster).was_called(); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
56 end); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
57 |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
58 it("should return one item", function () |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
59 local ok, ret = service:get_items("node", true); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
60 assert.truthy(ok); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
61 assert.same({ "1", ["1"] = "item 1" }, ret); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
62 end); |
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
63 |
9173
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
64 it("lets someone unsubscribe", function () |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
65 assert.truthy(service:remove_subscription("node", true, "someone")); |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
66 end); |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
67 |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
68 it("does not send notifications after subscription is removed", function () |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
69 assert.truthy(service:publish("node", true, "1", "item 1")); |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
70 assert.is_nil(notified["someone"]); |
c53663e13b51
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Matthew Wild <mwild1@gmail.com>
parents:
9171
diff
changeset
|
71 end); |
8647
638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
Kim Alvefur <zash@zash.se>
parents:
8564
diff
changeset
|
72 end); |
9004
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
73 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
74 describe("#issue1082", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
75 local service = pubsub.new(); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
76 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
77 it("creates a node with max_items = 1", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
78 assert.truthy(service:create("node", true, { max_items = 1 })); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
79 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
80 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
81 it("changes max_items to 2", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
82 assert.truthy(service:set_node_config("node", true, { max_items = 2 })); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
83 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
84 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
85 it("publishes one item", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
86 assert.truthy(service:publish("node", true, "1", "item 1")); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
87 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
88 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
89 it("should return one item", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
90 local ok, ret = service:get_items("node", true); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
91 assert.truthy(ok); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
92 assert.same({ "1", ["1"] = "item 1" }, ret); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
93 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
94 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
95 it("publishes another item", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
96 assert.truthy(service:publish("node", true, "2", "item 2")); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
97 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
98 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
99 it("should return two items", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
100 local ok, ret = service:get_items("node", true); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
101 assert.truthy(ok); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
102 assert.same({ |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
103 "2", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
104 "1", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
105 ["1"] = "item 1", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
106 ["2"] = "item 2", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
107 }, ret); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
108 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
109 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
110 it("publishes yet another item", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
111 assert.truthy(service:publish("node", true, "3", "item 3")); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
112 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
113 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
114 it("should still return only two items", function () |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
115 local ok, ret = service:get_items("node", true); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
116 assert.truthy(ok); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
117 assert.same({ |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
118 "3", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
119 "2", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
120 ["2"] = "item 2", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
121 ["3"] = "item 3", |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
122 }, ret); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
123 end); |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
124 |
50a0f405e6c9
util_pubsub_spec: Add test for #1082
Kim Alvefur <zash@zash.se>
parents:
8817
diff
changeset
|
125 end); |
9169
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
126 |
9174
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
127 describe("node config", function () |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
128 local service; |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
129 before_each(function () |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
130 service = pubsub.new(); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
131 service:create("test", true); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
132 end); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
133 it("access is forbidden for unaffiliated entities", function () |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
134 local ok, err = service:get_node_config("test", "stranger"); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
135 assert.is_falsy(ok); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
136 assert.equals("forbidden", err); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
137 end); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
138 it("returns an error for nodes that do not exist", function () |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
139 local ok, err = service:get_node_config("nonexistent", true); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
140 assert.is_falsy(ok); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
141 assert.equals("item-not-found", err); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
142 end); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
143 end); |
160032d55ff1
util.pubsub tests: Add initial node config tests
Matthew Wild <mwild1@gmail.com>
parents:
9173
diff
changeset
|
144 |
9169
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
145 describe("access model", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
146 describe("open", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
147 local service; |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
148 before_each(function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
149 service = pubsub.new(); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
150 -- Do not supply any config, 'open' should be default |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
151 service:create("test", true); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
152 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
153 it("should be the default", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
154 local ok, config = service:get_node_config("test", true); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
155 assert.equal("open", config.access_model); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
156 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
157 it("should allow anyone to subscribe", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
158 local ok = service:add_subscription("test", "stranger", "stranger"); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
159 assert.is_true(ok); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
160 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
161 it("should still reject outcast-affiliated entities", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
162 assert(service:set_affiliation("test", true, "enemy", "outcast")); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
163 local ok, err = service:add_subscription("test", "enemy", "enemy"); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
164 assert.is_falsy(ok); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
165 assert.equal("forbidden", err); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
166 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
167 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
168 describe("whitelist", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
169 local service; |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
170 before_each(function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
171 service = assert(pubsub.new()); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
172 assert.is_true(service:create("test", true, { access_model = "whitelist" })); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
173 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
174 it("should be present in the configuration", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
175 local ok, config = service:get_node_config("test", true); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
176 assert.equal("whitelist", config.access_model); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
177 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
178 it("should not allow anyone to subscribe", function () |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
179 local ok, err = service:add_subscription("test", "stranger", "stranger"); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
180 assert.is_false(ok); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
181 assert.equals("forbidden", err); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
182 end); |
9171
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
183 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
184 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
185 |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
186 describe("publish model", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
187 describe("publishers", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
188 local service; |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
189 before_each(function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
190 service = pubsub.new(); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
191 -- Do not supply any config, 'publishers' should be default |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
192 service:create("test", true); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
193 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
194 it("should be the default", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
195 local ok, config = service:get_node_config("test", true); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
196 assert.equal("publishers", config.publish_model); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
197 end); |
9169
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
198 it("should not allow anyone to publish", function () |
9171
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
199 assert.is_true(service:add_subscription("test", "stranger", "stranger")); |
9169
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
200 local ok, err = service:publish("test", "stranger", "item1", "foo"); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
201 assert.is_falsy(ok); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
202 assert.equals("forbidden", err); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
203 end); |
9171
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
204 it("should allow publishers to publish", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
205 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
206 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
207 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
208 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
209 it("should allow owners to publish", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
210 assert(service:set_affiliation("test", true, "myowner", "owner")); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
211 local ok = service:publish("test", "myowner", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
212 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
213 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
214 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
215 describe("open", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
216 local service; |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
217 before_each(function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
218 service = pubsub.new(); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
219 service:create("test", true, { publish_model = "open" }); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
220 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
221 it("should allow anyone to publish", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
222 local ok = service:publish("test", "stranger", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
223 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
224 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
225 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
226 describe("subscribers", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
227 local service; |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
228 before_each(function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
229 service = pubsub.new(); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
230 service:create("test", true, { publish_model = "subscribers" }); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
231 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
232 it("should not allow non-subscribers to publish", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
233 local ok, err = service:publish("test", "stranger", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
234 assert.is_falsy(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
235 assert.equals("forbidden", err); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
236 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
237 it("should allow subscribers to publish without an affiliation", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
238 assert.is_true(service:add_subscription("test", "stranger", "stranger")); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
239 local ok = service:publish("test", "stranger", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
240 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
241 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
242 it("should allow publishers to publish without a subscription", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
243 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
244 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
245 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
246 end); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
247 it("should allow owners to publish without a subscription", function () |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
248 assert(service:set_affiliation("test", true, "myowner", "owner")); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
249 local ok = service:publish("test", "myowner", "item1", "foo"); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
250 assert.is_true(ok); |
5f03fe90704f
util.pubsub tests: Add tests for publish_model (publishers, open, subscribers)
Matthew Wild <mwild1@gmail.com>
parents:
9169
diff
changeset
|
251 end); |
9169
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
252 end); |
3ec013185c15
util.pubsub tests: Add some initial access model tests (open and whitelist)
Matthew Wild <mwild1@gmail.com>
parents:
9159
diff
changeset
|
253 end); |
8558
5de663cef508
util_pubsub_spec: Beginnings of tests for util.pubsub
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
254 end); |