From 8335365fb4afb35b79995598c09f171f8b508d58 Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Tue, 6 Feb 2024 11:58:00 +0000 Subject: [PATCH] Fix expiry of static queue --- ruby/lib/ci/queue/static.rb | 2 +- ruby/test/ci/queue/static_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ruby/lib/ci/queue/static.rb b/ruby/lib/ci/queue/static.rb index 2be22f55..4c2f90c6 100644 --- a/ruby/lib/ci/queue/static.rb +++ b/ruby/lib/ci/queue/static.rb @@ -63,7 +63,7 @@ def created_at=(timestamp) end def expired? - (@created_at.to_f TEN_MINUTES) < CI::Queue.time_now.to_f + (@created_at.to_f + TEN_MINUTES) < CI::Queue.time_now.to_f end def populated? diff --git a/ruby/test/ci/queue/static_test.rb b/ruby/test/ci/queue/static_test.rb index 78e81fcf..9c11fc41 100644 --- a/ruby/test/ci/queue/static_test.rb +++ b/ruby/test/ci/queue/static_test.rb @@ -4,6 +4,14 @@ class CI::Queue::StaticTest < Minitest::Test include SharedQueueAssertions + def test_expired + queue = CI::Queue.from_uri('list:foo:bar:plop%3Ffizz', config) + assert queue.expired? + + queue.created_at = Time.now + refute queue.expired? + end + private def build_queue