Sha256: 52ef435811175cf8f5fafc5aad2190b7e717abebc0c7c1a2b40c738b68da675d

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

require 'minitest'
require "minitest/autorun"
require 'pry'

$:.unshift(".")
require 'resque_stuck_queue'
require File.join(File.expand_path(File.dirname(__FILE__)), "resque", "set_redis_key")
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")

class TestLagTime < Minitest::Test

  include TestHelper

  def setup
    Resque::StuckQueue.redis = Redis.new
    Resque::StuckQueue.redis.flushall
    Resque::StuckQueue.config[:abort_on_exception] = true
  end

  def test_triggers_handler_with_lagtime
    Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
    Resque::StuckQueue.config[:heartbeat] = 1
    @lagtime = 0
    Resque::StuckQueue.config[:triggered_handler] = proc { |queue_name, lagtime| @lagtime = lagtime }
    start_and_stop_loops_after(5)

    # check handler did get called
    assert @lagtime > 0, "lagtime shoudl be set"
    assert @lagtime < 5, "lagtime shoudl be set"
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resque_stuck_queue-0.2.1 test/test_lagtime.rb
resque_stuck_queue-0.2.0 test/test_lagtime.rb