From 0e9dae190b3eb9f655c42a2962b0f57e1f3c036a Mon Sep 17 00:00:00 2001 From: Christina Date: Thu, 23 Nov 2023 14:29:25 +0100 Subject: [PATCH] add spec --- spec/policies_spec.cr | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/policies_spec.cr b/spec/policies_spec.cr index 268a65a8ab..511997e069 100644 --- a/spec/policies_spec.cr +++ b/spec/policies_spec.cr @@ -4,6 +4,7 @@ describe LavinMQ::VHost do definitions = { "max-length" => JSON::Any.new(10_i64), "alternate-exchange" => JSON::Any.new("dead-letters"), + "unsupportued" => JSON::Any.new("unsupported"), } vhost = Server.vhosts.create("add_policy") @@ -212,6 +213,22 @@ describe LavinMQ::VHost do ch.queue_declare(q.name, passive: true)[:message_count].should eq 2 end end + + it "effective_policy_definition should not include unsupported policies" do + supported_policies = {"max-length", "max-length-bytes", + "message-ttl", "expires", "overflow", + "dead-letter-exchange", "dead-letter-routing-key", + "federation-upstream", "federation-upstream-set", + "delivery-limit", "max-age", "alternate-exchange", + "delayed-message"} + vhost.queues["test"] = LavinMQ::Queue.new(vhost, "test") + vhost.add_policy("test", "^.*$", "all", definitions, -10_i8) + sleep 0.01 + vhost.queues["test"].details_tuple[:effective_policy_definition].as(Hash(String, JSON::Any)).each do |k, v| + supported_policies.includes?(k).should be_true + end + vhost.delete_policy("test") + end end describe "together with arguments" do