Sha256: 4dfe63d8cadd62be21a678b2bea9f56276e72d0f03a1816754354e76747737d3

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

require 'test_helper'
require 'open3'

module Sidekiq
  describe Lock do
    it 'automatically loads lock middleware for sidekiq server' do
      skip 'Sidekiq 7+ does not print out middleware information' if Sidekiq::VERSION >= '7'

      cmd = 'sidekiq -r ./test/test_workers.rb -v'
      buffer = ''

      # very not fancy (https://78.media.tumblr.com/tumblr_lzkpw7DAl21qhy6c9o2_400.gif)
      # solution, but should do the job
      Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
        begin
          Timeout.timeout(5) do
            until stdout.eof? do
              buffer << stdout.read_nonblock(16)
            end
          end
        rescue Timeout::Error
          Process.kill('KILL', thread.pid)
        end
      end

      assert_match(/\s?Middleware:.*Sidekiq::Lock::Middleware/i, buffer)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-lock-0.6.0 test/lib/lock_test.rb