diff --git a/spec/mqtt/integrations/message_qos_spec.cr b/spec/mqtt/integrations/message_qos_spec.cr index 6109f76376..dfb28d8ce2 100644 --- a/spec/mqtt/integrations/message_qos_spec.cr +++ b/spec/mqtt/integrations/message_qos_spec.cr @@ -260,5 +260,29 @@ module MqttSpecs end end end + + it "should not enqueue messages with QoS 0 if no client is subscribed to the session" do + with_server do |server| + with_client_io(server) do |io| + connect(io) + topic_filters = mk_topic_filters({"a/b", 0u8}) + subscribe(io, topic_filters: topic_filters) + disconnect(io) + end + + with_client_io(server) do |publisher_io| + connect(publisher_io, client_id: "publisher") + publish(publisher_io, topic: "a/b", qos: 0u8) + disconnect(publisher_io) + end + + with_client_io(server) do |io| + connect(io) + pkt = read_packet(io) + pkt.should be_nil + disconnect(io) + end + end + end end end