Sha256: a981dc357cfd00260280d1319cb24c37af03e1155f7b9529300dc77e5213e22f

Contents?: true

Size: 1.52 KB

Versions: 31

Compression:

Stored size: 1.52 KB

Contents

describe Ufo::Task do
  before(:each) do
    create_ufo_project
  end
  let(:options) do
    {
      mute: true
    }
  end
  let(:task_definition) { "hi-migrate-prod" }

  context "hi-migrate-prod" do
    it "should migrate the database" do
      task.run

      expect(task.ecs).to have_received(:run_task)
    end

    it "should wait for the command to finish" do
      expect do
        task(wait: true, timeout: 600).run
        expect(task.ecs).to have_received(:run_task)
      end.to raise_error(SystemExit) do |error|
        expect(error.status).to eq(5)
      end
    end
  end

  # mocks
  def ecs_client
    ecs = double("ecs")
    ecs_container = double("ecs_container")
    fake_response = double('fake-response').as_null_object
    allow(ecs).to receive(:run_task).and_return(fake_response)
    allow(ecs).to receive(:wait_until).and_return(fake_response)
    allow(ecs).to receive(:describe_tasks).and_return(OpenStruct.new({
      tasks: [OpenStruct.new(containers: [ecs_container])]
    }))
    allow(ecs).to receive(:list_task_definitions).and_return(fake_response)
    allow(ecs).to receive(:describe_task_definition).and_return(fake_response)
    allow(ecs_container).to receive(:exit_code).and_return(5)
    ecs
  end

  def task option_overwrites = {}
    @task ||=
      begin
        task = Ufo::Task.new(task_definition, options.merge(option_overwrites))
        allow(task).to receive(:ensure_log_group_exist) # stub not so not called
        allow(task).to receive(:ecs).and_return(ecs_client)
        task
      end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ufo-5.0.7 spec/lib/task_spec.rb
ufo-5.0.6 spec/lib/task_spec.rb
ufo-5.0.5 spec/lib/task_spec.rb
ufo-5.0.4 spec/lib/task_spec.rb
ufo-5.0.3 spec/lib/task_spec.rb
ufo-5.0.2 spec/lib/task_spec.rb
ufo-5.0.1 spec/lib/task_spec.rb
ufo-5.0.0 spec/lib/task_spec.rb
ufo-4.6.3 spec/lib/task_spec.rb
ufo-4.6.2 spec/lib/task_spec.rb
ufo-4.6.1 spec/lib/task_spec.rb
ufo-4.6.0 spec/lib/task_spec.rb
ufo-4.5.11 spec/lib/task_spec.rb
ufo-4.5.10 spec/lib/task_spec.rb
ufo-4.5.9 spec/lib/task_spec.rb
ufo-4.5.8 spec/lib/task_spec.rb
ufo-4.5.7 spec/lib/task_spec.rb
ufo-4.5.6 spec/lib/task_spec.rb
ufo-4.5.5 spec/lib/task_spec.rb
ufo-4.5.4 spec/lib/task_spec.rb