Sha256: d5d12550e47015d774efca2aa9f0d4bf35a237279407b6b870aa293014286908

Contents?: true

Size: 809 Bytes

Versions: 4

Compression:

Stored size: 809 Bytes

Contents

require 'helper'
require 'sidekiq/scheduled'

class TestScheduling < MiniTest::Unit::TestCase
  describe 'middleware' do
    before do
      @redis = MiniTest::Mock.new
      # Ugh, this is terrible.
      Sidekiq.instance_variable_set(:@redis, @redis)

      def @redis.with; yield self; end
    end

    class ScheduledWorker
      include Sidekiq::Worker
      def perform(x)
      end
    end

    it 'schedules a job via interval' do
      @redis.expect :zadd, 1, ['schedule', String, String]
      assert_equal true, ScheduledWorker.perform_in(600, 'mike')
      @redis.verify
    end

    it 'schedules a job via timestamp' do
      @redis.expect :zadd, 1, ['schedule', String, String]
      assert_equal true, ScheduledWorker.perform_in(5.days.from_now, 'mike')
      @redis.verify
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-2.0.3 test/test_scheduling.rb
sidekiq-2.0.2 test/test_scheduling.rb
sidekiq-2.0.1 test/test_scheduling.rb
sidekiq-2.0.0 test/test_scheduling.rb