Sha256: c49a90abe24f7629ceddadd3f33e27d9cfb5201f5f0aa7135e3712ec2ba56c67
Contents?: true
Size: 1.34 KB
Versions: 16
Compression:
Stored size: 1.34 KB
Contents
require 'test_helper' class WorkUnitTest < Test::Unit::TestCase context "A WorkUnit" do setup do @unit = CloudCrowd::WorkUnit.make @job = @unit.job end subject { @unit } should_belong_to :job should_validate_presence_of :job_id, :status, :input, :action should "know if its done" do assert !@unit.complete? @unit.status = SUCCEEDED assert @unit.complete? @unit.status = FAILED assert @unit.complete? end should "have JSON that includes job attributes" do job = Job.make unit_data = JSON.parse(job.work_units.first.to_json) assert unit_data['job_id'] == job.id assert unit_data['action'] == job.action assert JSON.parse(job.inputs).include? unit_data['input'] end should "be able to retry, on failure" do @unit.update_attribute :worker_pid, 7337 assert @unit.attempts == 0 @unit.fail('oops', 10) assert @unit.worker_pid == nil assert @unit.attempts == 1 assert @unit.processing? @unit.fail('oops again', 10) assert @unit.attempts == 2 assert @unit.processing? assert @unit.job.processing? @unit.fail('oops one last time', 10) assert @unit.attempts == 3 assert @unit.failed? assert @unit.job.any_work_units_failed? end end end
Version data entries
16 entries across 16 versions & 2 rubygems