Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 10572:d960c703e6b3
util.pubsub: Cover subscription filter in a partial test
I'm not sure I understand spies well enough to test that the arguments
and return values are as expected.
Better than nothing at least.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 26 Dec 2019 01:52:14 +0100 |
parent | 10541:6c6ff4509082 |
child | 10573:3b8431eed785 |
comparison
equal
deleted
inserted
replaced
10571:cfeb0077c9e9 | 10572:d960c703e6b3 |
---|---|
481 end); | 481 end); |
482 | 482 |
483 | 483 |
484 end); | 484 end); |
485 | 485 |
486 describe("subscriber filter", function () | |
487 it("works", function () | |
488 local filter = spy.new(function (subs) | |
489 return {["modified"] = true}; | |
490 end); | |
491 local broadcaster = spy.new(function (notif_type, node_name, subscribers, item) -- luacheck: ignore 212 | |
492 end); | |
493 local service = pubsub.new({ | |
494 subscriber_filter = filter; | |
495 broadcaster = broadcaster; | |
496 }); | |
497 | |
498 local ok = service:create("node", true); | |
499 assert.truthy(ok); | |
500 | |
501 local ok = service:add_subscription("node", true, "someone"); | |
502 assert.truthy(ok); | |
503 | |
504 local ok = service:publish("node", true, "1", "item"); | |
505 assert.truthy(ok); | |
506 -- TODO how to match table arguments? | |
507 assert.spy(filter).was_called(); | |
508 assert.spy(broadcaster).was_called(); | |
509 end); | |
510 end); | |
511 | |
486 end); | 512 end); |