Sha256: 9137fc0964b3f7f25e3f303ad3916b5544f9f40f28d1666376f5b0bce3b71587
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
require 'test_helper' class Workhorse::WorkerTest < WorkhorseTest # This test makes sure that concurrent jobs always work in different database # connections. def test_db_connections 2.times do Workhorse.enqueue DbConnectionTestJob.new end work 0.2, polling_interval: 0.2 assert_equal 2, DbConnectionTestJob.db_connections.count assert_equal 2, DbConnectionTestJob.db_connections.uniq.count end def test_success Workhorse.enqueue BasicJob.new(sleep_time: 0.1) work 0.2, polling_interval: 0.2 assert_equal 'succeeded', Workhorse::DbJob.first.state end def test_exception Workhorse.enqueue FailingTestJob work 0.2, polling_interval: 0.2 assert_equal 'failed', Workhorse::DbJob.first.state end def test_syntax_exception Workhorse.enqueue SyntaxErrorJob work 0.2, polling_interval: 0.2 assert_equal 'failed', Workhorse::DbJob.first.state end def test_on_exception old_callback = Workhorse.on_exception exception = nil Workhorse.on_exception = proc do |e| exception = e end Workhorse.enqueue FailingTestJob.new work 0.2, polling_interval: 0.2 assert_equal exception.message, FailingTestJob::MESSAGE ensure Workhorse.on_exception = old_callback end end
Version data entries
5 entries across 5 versions & 1 rubygems