Sha256: a835ac0c44baa8e15484d90208a3893b83f63c38643e7987708ac0ab0f03839d

Contents?: true

Size: 1.9 KB

Versions: 26

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

require File.expand_path("../../test_helper", File.dirname(__FILE__))

class ResqueWorkerTest < Minitest::Test
  # NOTE: It appears there are some bugs in resque for JRUBY, not coverband, so excluding these tests on JRUBY
  # if folks hit issues with Coverband and resque this could be a resque issue, reach out with details.
  # I also highly recommend moving to sidekiq.
  unless RUBY_PLATFORM == "java"
    def enqueue_and_run_job
      Resque.enqueue(TestResqueJob)
      ENV["QUEUE"] = "resque_coverband"
      worker = Resque::Worker.new
      worker.startup
      worker.work_one_job
    end

    def setup
      super
      Coverband.configure do |config|
        config.background_reporting_enabled = false
      end
      Coverband.start
      redis = Coverband.configuration.store.instance_eval { @redis }
      Resque.redis = redis
    end

    test "resque job coverage" do
      relative_job_file = "./test/coverband/integrations/test_resque_job.rb"
      resque_job_file = File.expand_path("./test_resque_job.rb", File.dirname(__FILE__))
      require resque_job_file

      enqueue_and_run_job

      assert !Coverband::Background.running?

      # TODO: There is a test only type issue where the test is looking at eager data
      # it merged eager and eager for merged and runtime is eager
      Coverband.runtime_coverage!
      report = Coverband.configuration.store.get_coverage_report

      if RUBY_PLATFORM == "java"
        # NOTE: the todo test only issue seems to be slightly different in JRuby
        # were nothing is showing up as runtime Coverage... This appears to be a test only issue
        assert_equal 1, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
      else
        assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
        assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]["data"][6]
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
coverband-6.1.2 test/coverband/integrations/resque_worker_test.rb
coverband-6.1.2.rc.1 test/coverband/integrations/resque_worker_test.rb
coverband-6.1.1 test/coverband/integrations/resque_worker_test.rb
coverband-6.1.0 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.3.rc.4 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.3.rc.3 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.3.rc.2 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.3.rc.1 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.2 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.1 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.1.rc.1 test/coverband/integrations/resque_worker_test.rb
coverband-6.0.0 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.6 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.3.2 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.5 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.3.1 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.4 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.3 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.2 test/coverband/integrations/resque_worker_test.rb
coverband-5.2.6.rc.1 test/coverband/integrations/resque_worker_test.rb