Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 10541:6c6ff4509082
tests: Silence [luacheck] warnings
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Dec 2019 21:33:10 +0100 |
parent | 10356:0a2d7efca039 |
child | 10572:d960c703e6b3 |
comparison
equal
deleted
inserted
replaced
10540:375d31225d53 | 10541:6c6ff4509082 |
---|---|
99 | 99 |
100 it("automatically creates node with requested config", function () | 100 it("automatically creates node with requested config", function () |
101 assert(service:publish("node", true, "1", "item 1", { myoption = true })); | 101 assert(service:publish("node", true, "1", "item 1", { myoption = true })); |
102 | 102 |
103 local ok, config = assert(service:get_node_config("node", true)); | 103 local ok, config = assert(service:get_node_config("node", true)); |
104 assert.truthy(ok); | |
104 assert.equals(true, config.myoption); | 105 assert.equals(true, config.myoption); |
105 end); | 106 end); |
106 | 107 |
107 it("fails to publish to a node with differing config", function () | 108 it("fails to publish to a node with differing config", function () |
108 local ok, err = service:publish("node", true, "1", "item 2", { myoption = false }); | 109 local ok, err = service:publish("node", true, "1", "item 2", { myoption = false }); |
227 -- Do not supply any config, 'open' should be default | 228 -- Do not supply any config, 'open' should be default |
228 service:create("test", true); | 229 service:create("test", true); |
229 end); | 230 end); |
230 it("should be the default", function () | 231 it("should be the default", function () |
231 local ok, config = service:get_node_config("test", true); | 232 local ok, config = service:get_node_config("test", true); |
233 assert.truthy(ok); | |
232 assert.equal("open", config.access_model); | 234 assert.equal("open", config.access_model); |
233 end); | 235 end); |
234 it("should allow anyone to subscribe", function () | 236 it("should allow anyone to subscribe", function () |
235 local ok = service:add_subscription("test", "stranger", "stranger"); | 237 local ok = service:add_subscription("test", "stranger", "stranger"); |
236 assert.is_true(ok); | 238 assert.is_true(ok); |
248 service = assert(pubsub.new()); | 250 service = assert(pubsub.new()); |
249 assert.is_true(service:create("test", true, { access_model = "whitelist" })); | 251 assert.is_true(service:create("test", true, { access_model = "whitelist" })); |
250 end); | 252 end); |
251 it("should be present in the configuration", function () | 253 it("should be present in the configuration", function () |
252 local ok, config = service:get_node_config("test", true); | 254 local ok, config = service:get_node_config("test", true); |
255 assert.truthy(ok); | |
253 assert.equal("whitelist", config.access_model); | 256 assert.equal("whitelist", config.access_model); |
254 end); | 257 end); |
255 it("should not allow anyone to subscribe", function () | 258 it("should not allow anyone to subscribe", function () |
256 local ok, err = service:add_subscription("test", "stranger", "stranger"); | 259 local ok, err = service:add_subscription("test", "stranger", "stranger"); |
257 assert.is_false(ok); | 260 assert.is_false(ok); |
292 -- Do not supply any config, 'publishers' should be default | 295 -- Do not supply any config, 'publishers' should be default |
293 service:create("test", true); | 296 service:create("test", true); |
294 end); | 297 end); |
295 it("should be the default", function () | 298 it("should be the default", function () |
296 local ok, config = service:get_node_config("test", true); | 299 local ok, config = service:get_node_config("test", true); |
300 assert.truthy(ok); | |
297 assert.equal("publishers", config.publish_model); | 301 assert.equal("publishers", config.publish_model); |
298 end); | 302 end); |
299 it("should not allow anyone to publish", function () | 303 it("should not allow anyone to publish", function () |
300 assert.is_true(service:add_subscription("test", "stranger", "stranger")); | 304 assert.is_true(service:add_subscription("test", "stranger", "stranger")); |
301 local ok, err = service:publish("test", "stranger", "item1", "foo"); | 305 local ok, err = service:publish("test", "stranger", "item1", "foo"); |
302 assert.is_falsy(ok); | 306 assert.is_falsy(ok); |
303 assert.equals("forbidden", err); | 307 assert.equals("forbidden", err); |
304 end); | 308 end); |
305 it("should allow publishers to publish", function () | 309 it("should allow publishers to publish", function () |
306 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); | 310 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); |
311 -- luacheck: ignore 211/err | |
307 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); | 312 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); |
308 assert.is_true(ok); | 313 assert.is_true(ok); |
309 end); | 314 end); |
310 it("should allow owners to publish", function () | 315 it("should allow owners to publish", function () |
311 assert(service:set_affiliation("test", true, "myowner", "owner")); | 316 assert(service:set_affiliation("test", true, "myowner", "owner")); |
340 local ok = service:publish("test", "stranger", "item1", "foo"); | 345 local ok = service:publish("test", "stranger", "item1", "foo"); |
341 assert.is_true(ok); | 346 assert.is_true(ok); |
342 end); | 347 end); |
343 it("should allow publishers to publish without a subscription", function () | 348 it("should allow publishers to publish without a subscription", function () |
344 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); | 349 assert(service:set_affiliation("test", true, "mypublisher", "publisher")); |
350 -- luacheck: ignore 211/err | |
345 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); | 351 local ok, err = service:publish("test", "mypublisher", "item1", "foo"); |
346 assert.is_true(ok); | 352 assert.is_true(ok); |
347 end); | 353 end); |
348 it("should allow owners to publish without a subscription", function () | 354 it("should allow owners to publish without a subscription", function () |
349 assert(service:set_affiliation("test", true, "myowner", "owner")); | 355 assert(service:set_affiliation("test", true, "myowner", "owner")); |