Software / code / prosody
Comparison
spec/util_pubsub_spec.lua @ 9816:7f84d7f77a00 0.11
util.pubsub: Add support for requesting multiple specific items (needed for #1305)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 28 Jan 2019 01:41:01 +0100 |
| parent | 9742:18eca6afb367 |
| child | 9840:ec353524b739 |
comparison
equal
deleted
inserted
replaced
| 9814:5eb4ef537e98 | 9816:7f84d7f77a00 |
|---|---|
| 167 ["3"] = "item 3", | 167 ["3"] = "item 3", |
| 168 }, ret); | 168 }, ret); |
| 169 end); | 169 end); |
| 170 | 170 |
| 171 end); | 171 end); |
| 172 | |
| 173 describe("the thing", function () | |
| 174 randomize(false); -- These tests are ordered | |
| 175 | |
| 176 local service = pubsub.new(); | |
| 177 | |
| 178 it("creates a node with some items", function () | |
| 179 assert.truthy(service:create("node", true, { max_items = 3 })); | |
| 180 assert.truthy(service:publish("node", true, "1", "item 1")); | |
| 181 assert.truthy(service:publish("node", true, "2", "item 2")); | |
| 182 assert.truthy(service:publish("node", true, "3", "item 3")); | |
| 183 end); | |
| 184 | |
| 185 it("should return the requested item", function () | |
| 186 local ok, ret = service:get_items("node", true, "1"); | |
| 187 assert.truthy(ok); | |
| 188 assert.same({ "1", ["1"] = "item 1" }, ret); | |
| 189 end); | |
| 190 | |
| 191 it("should return multiple requested items", function () | |
| 192 local ok, ret = service:get_items("node", true, { "1", "2" }); | |
| 193 assert.truthy(ok); | |
| 194 assert.same({ | |
| 195 "1", | |
| 196 "2", | |
| 197 ["1"] = "item 1", | |
| 198 ["2"] = "item 2", | |
| 199 }, ret); | |
| 200 end); | |
| 201 end); | |
| 202 | |
| 172 | 203 |
| 173 describe("node config", function () | 204 describe("node config", function () |
| 174 local service; | 205 local service; |
| 175 before_each(function () | 206 before_each(function () |
| 176 service = pubsub.new(); | 207 service = pubsub.new(); |