From 8a97d634a4c5c5d046424c227a4b26bb9f486481 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 6 Jan 2022 01:18:35 +0100 Subject: util.pubsub: Fix item store resize to "max" Previously this would end up passing the "max" directly to the underlying storage. --- spec/util_pubsub_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec/util_pubsub_spec.lua') diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua index 2dc5ca60..45a612a0 100644 --- a/spec/util_pubsub_spec.lua +++ b/spec/util_pubsub_spec.lua @@ -169,6 +169,26 @@ describe("util.pubsub", function () }, ret); end); + it("has a default max_items", function () + assert.truthy(service.config.max_items); + end) + + it("changes max_items to max", function () + assert.truthy(service:set_node_config("node", true, { max_items = "max" })); + end); + + it("publishes some more items", function() + for i = 4, service.config.max_items + 5 do + assert.truthy(service:publish("node", true, tostring(i), "item " .. tostring(i))); + end + end); + + it("should still return only two items", function () + local ok, ret = service:get_items("node", true); + assert.truthy(ok); + assert.same(service.config.max_items, #ret); + end); + end); describe("the thing", function () -- cgit v1.2.3