Sha256: a25690cb020ca758f9573450cbc0a2ef6ed0d84ef2f722aea5172f5a0ee52280

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

require 'minitest/autorun'
require 'active_record'
require 'active_job'
require 'pry'
require 'colorize'
require 'mysql2'
require 'benchmark'
require 'jobs'

class WorkhorseTest < ActiveSupport::TestCase
  def setup
    Workhorse::DbJob.delete_all
  end

  protected

  def capture_log(level: :debug)
    io = StringIO.new
    logger = Logger.new(io, level: level)
    yield logger
    io.close
    return io.string
  end

  def work(time = 2, options = {})
    options[:pool_size] ||= 5
    options[:polling_interval] ||= 1

    with_worker(options) do
      sleep time
    end
  end

  def with_worker(options = {})
    w = Workhorse::Worker.new(**options)
    w.start
    begin
      yield(w)
    ensure
      w.shutdown
    end
  end
end

ActiveRecord::Base.establish_connection(
  adapter:  'mysql2',
  database: ENV['DB_NAME'] || 'workhorse',
  username: ENV['DB_USERNAME'] || 'root',
  password: ENV['DB_PASSWORD'] || '',
  host:     ENV['DB_HOST'] || '127.0.0.1',
  pool:     10
)

require 'db_schema'
require 'workhorse'

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
workhorse-1.2.15 test/lib/test_helper.rb
workhorse-1.2.14 test/lib/test_helper.rb
workhorse-1.2.13 test/lib/test_helper.rb
workhorse-1.2.12 test/lib/test_helper.rb
workhorse-1.2.11 test/lib/test_helper.rb
workhorse-1.2.10 test/lib/test_helper.rb
workhorse-1.2.9 test/lib/test_helper.rb
workhorse-1.2.8 test/lib/test_helper.rb
workhorse-1.2.7 test/lib/test_helper.rb
workhorse-1.2.6 test/lib/test_helper.rb
workhorse-1.2.5 test/lib/test_helper.rb