Sha256: f1be0c3cd2958b4eb491c0fd66786297fcffc70a00035cf8cc5bd612870da2e3

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require 'test_helper'

module Chillout
  class WorkerTest < ChilloutTestCase
    def setup
      @dispatcher = stub
      @queue = stub
      @container = stub
      @logger = stub(info: "", error: "")
      @container_class = stub(new: @container)
      @worker = Worker.new(@dispatcher, @queue, @logger, @container_class)
    end

    def test_get_all_containers_to_process_pops_all_existings_jobs_from_queue
      @queue.expects(:pop).times(3).returns(:container1, :container2).then.raises(ThreadError)
      all_jobs = @worker.get_all_containers_to_process
      assert_equal 2, all_jobs.count
      assert_includes all_jobs, :container1
      assert_includes all_jobs, :container2
    end

    def test_merge_containers_to_one
      @container.expects(:merge).with(:container1)
      @container.expects(:merge).with(:container2)
      result = @worker.merge_containers([:container1, :container2])
      assert_equal @container, result
    end

    def test_send_creations_just_send_creations_with_dispatcher
      @dispatcher.expects(:send_creations).with(:creations_container)
      @worker.send_creations(:creations_container)
    end

    def test_send_creations_with_interuption
      @dispatcher.stubs(:send_creations).raises(Dispatcher::SendCreationsFailed)
      @queue.expects(:<<).with(:creations_container)
      @worker.send_creations(:creations_container)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chillout-0.4.0 test/worker_test.rb
chillout-0.3.0 test/worker_test.rb
chillout-0.2.3 test/worker_test.rb