Software /
code /
prosody
Comparison
spec/util_pubsub_spec.lua @ 9004:50a0f405e6c9
util_pubsub_spec: Add test for #1082
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 10 Jul 2018 00:22:05 +0200 |
parent | 8817:9a3066a580ad |
child | 9159:a0fd7064f4ac |
comparison
equal
deleted
inserted
replaced
9003:a971023e9b6e | 9004:50a0f405e6c9 |
---|---|
62 assert.truthy(ok); | 62 assert.truthy(ok); |
63 assert.same({ "1", ["1"] = "item 1" }, ret); | 63 assert.same({ "1", ["1"] = "item 1" }, ret); |
64 end); | 64 end); |
65 | 65 |
66 end); | 66 end); |
67 | |
68 describe("#issue1082", function () | |
69 local service = pubsub.new(); | |
70 | |
71 it("creates a node with max_items = 1", function () | |
72 assert.truthy(service:create("node", true, { max_items = 1 })); | |
73 end); | |
74 | |
75 it("changes max_items to 2", function () | |
76 assert.truthy(service:set_node_config("node", true, { max_items = 2 })); | |
77 end); | |
78 | |
79 it("publishes one item", function () | |
80 assert.truthy(service:publish("node", true, "1", "item 1")); | |
81 end); | |
82 | |
83 it("should return one item", function () | |
84 local ok, ret = service:get_items("node", true); | |
85 assert.truthy(ok); | |
86 assert.same({ "1", ["1"] = "item 1" }, ret); | |
87 end); | |
88 | |
89 it("publishes another item", function () | |
90 assert.truthy(service:publish("node", true, "2", "item 2")); | |
91 end); | |
92 | |
93 it("should return two items", function () | |
94 local ok, ret = service:get_items("node", true); | |
95 assert.truthy(ok); | |
96 assert.same({ | |
97 "2", | |
98 "1", | |
99 ["1"] = "item 1", | |
100 ["2"] = "item 2", | |
101 }, ret); | |
102 end); | |
103 | |
104 it("publishes yet another item", function () | |
105 assert.truthy(service:publish("node", true, "3", "item 3")); | |
106 end); | |
107 | |
108 it("should still return only two items", function () | |
109 local ok, ret = service:get_items("node", true); | |
110 assert.truthy(ok); | |
111 assert.same({ | |
112 "3", | |
113 "2", | |
114 ["2"] = "item 2", | |
115 ["3"] = "item 3", | |
116 }, ret); | |
117 end); | |
118 | |
119 end); | |
67 end); | 120 end); |