Sha256: 2f41e1efbc67fc399bdbc85567e867c151fe9a6496cb2ef2713cde59e0d12878
Contents?: true
Size: 1.49 KB
Versions: 4
Compression:
Stored size: 1.49 KB
Contents
require 'test_helper' class TestFailure < Test::Unit::TestCase context "See Kthxbye Failures" do setup do Kthxbye.redis.flushall end should "create a failure" do id = Kthxbye.enqueue("test", SimpleJob, 1, 2) assert Kthxbye::Failure.create(Kthxbye::Job.find(id, "test"), Exception.new("Test!")) assert_not_nil f = Kthxbye::Failure.all.first assert_equal "Exception", f['type'] assert_equal "Test!", f['error'] assert_equal id, f['job'] end should "insert and clear an exception" do id = Kthxbye.enqueue("test", SimpleJob, 1, 2) Kthxbye::Failure.create(Kthxbye::Job.find(id, "test"), Exception.new("Test!")) assert_equal 1, Kthxbye::Failure.all.size assert Kthxbye::Failure.clear_exception(id) assert_equal 0, Kthxbye::Failure.all.size end should "retry a job that failed" do id = Kthxbye.enqueue("test", BadJob) worker = Kthxbye::Worker.new("test", 0) worker.run assert_equal 1, Kthxbye::Failure.all.size assert_equal 1, Kthxbye::Failure.find(id)['attempts'] Kthxbye::Job.find(id, "test").rerun assert_equal 1, Kthxbye.size("test") worker.run do assert_equal Kthxbye::Job.find(id, "test"), worker.current_job end # note, we only store one error for a job failure. we will increment the failure count assert_equal 1, Kthxbye::Failure.all.size assert_equal 2, Kthxbye::Failure.find(id)['attempts'] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kthxbye-1.0.4 | test/test_failure.rb |
kthxbye-1.0.2 | test/test_failure.rb |
kthxbye-1.0.1 | test/test_failure.rb |
kthxbye-1.0.0 | test/test_failure.rb |