Sha256: ac283726c0b3111809f78b50d374f6698ef7c54e581e4622a28dad4a6fc2b283

Contents?: true

Size: 940 Bytes

Versions: 62

Compression:

Stored size: 940 Bytes

Contents

require 'test_helper'

module Workarea
  class SchedulerTest < TestCase
    class MockWorker
      include Sidekiq::Worker

      def perform(*)
      end
    end

    setup :setup_sidekiq
    teardown :teardown_sidekiq

    def setup_sidekiq
      Sidekiq::Testing.disable!

      @scheduled_set = Sidekiq::ScheduledSet.new
      @scheduled_set.clear
    end

    def teardown_sidekiq
      Sidekiq::Testing.inline!
    end

    def test_adding_and_removing_a_job
      scheduler = Scheduler.new(
        worker: MockWorker,
        at: 1.week.from_now,
        args: [1, 2, 3]
      )

      scheduler.perform
      first_job_id = scheduler.job_id
      assert_equal(1, @scheduled_set.size)

      scheduler.perform
      second_job_id = scheduler.job_id
      assert_equal(1, @scheduled_set.size)

      assert(first_job_id.present?)
      assert(second_job_id.present?)
      refute_equal(first_job_id, second_job_id)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.26 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.45 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.25 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.23 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.44 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.22 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.43 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.21 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.42 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.20 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.41 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.19 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.40 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.18 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.39 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.17 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.38 test/lib/workarea/scheduler_test.rb
workarea-core-3.5.16 test/lib/workarea/scheduler_test.rb
workarea-core-3.4.37 test/lib/workarea/scheduler_test.rb