Sha256: 789dc4c4188efbf48997b32162d54e7f1c1d47b532319740be798d36283e9c0f
Contents?: true
Size: 1.45 KB
Versions: 25
Compression:
Stored size: 1.45 KB
Contents
require 'test_helper' class WorkerTest < Test::Unit::TestCase context "A CloudCrowd::Worker" do setup do @node = Node.new.instance_variable_get(:@app) @unit = WorkUnit.make @worker = Worker.new(@node, JSON.parse(@unit.to_json)) end should "instantiate correctly" do assert @worker.pid == $$ assert @worker.unit['id'] == @unit.id assert @worker.status == @unit.status assert @worker.node == @node assert @worker.time_taken > 0 end should "be able to retry operations that must succeed" do @worker.instance_variable_set :@retry_wait, 0.01 @worker.expects(:log).at_least(3) tries = 0 @worker.keep_trying_to("do something critical") do tries += 1; raise 'hell' unless tries > 3 assert "made it through" end end should "be able to run an action and try to complete it" do GraphicsMagick.any_instance.expects(:process).returns('the answer') GraphicsMagick.any_instance.expects(:cleanup_work_directory) @worker.expects(:complete_work_unit).with({'output' => 'the answer'}.to_json) @worker.run_work_unit end should "enchance the options that an action receives with extra info" do opts = @worker.enhanced_unit_options assert opts['work_unit_id'] == @unit.id assert opts['job_id'] == @unit.job.id assert opts['attempts'] == @unit.attempts end end end
Version data entries
25 entries across 25 versions & 3 rubygems