Sha256: bd4d8c838568927f6eeba1cbc3cc7b7d6ff05cb5deba9a512410456a31a6d1ce

Contents?: true

Size: 1.72 KB

Versions: 12

Compression:

Stored size: 1.72 KB

Contents

describe Ufo::Logs do
  let(:logs) do
    logs = Ufo::Logs.new("test-web", {})
    allow(logs).to receive(:exit).and_return(null)
    allow(logs).to receive(:info).and_return(null)
    allow(logs).to receive(:ecs).and_return(ecs)
    logs
  end
  let(:ecs) do
    ecs = double(:ecs).as_null_object
    allow(ecs).to receive(:describe_task_definition).and_return(mock_response(fixture))
    ecs
  end
  let(:null) { double(:null).as_null_object }

  context "awslogs conf" do
    let(:fixture) { "spec/fixtures/mocks/logs/awslogs.json" }
    it "find_log_group_name" do
      log_group_name = logs.find_log_group_name
      expect(log_group_name).to eq({"awslogs-group" => "ecs/demo-web", "awslogs-region" => "us-west-2", "awslogs-stream-prefix" => "demo" })
    end
  end

  context "not a awslogs conf" do
    let(:fixture) { "spec/fixtures/mocks/logs/no-awslogs.json" }
    it "find_log_group_name" do
      log_group_name = logs.find_log_group_name
      expect(log_group_name).to be nil
    end
  end

  def mock_response(file)
    data = JSON.load(IO.read(file))

    td = data["task_definition"]
    container_definitions = td["container_definitions"].map do |c|
      l = c["log_configuration"]
      log_configuration = Aws::ECS::Types::LogConfiguration.new(
        log_driver: l["log_driver"],
        options: l["options"],
      )
      Aws::ECS::Types::ContainerDefinition.new(
        name: c["name"],
        log_configuration: log_configuration,
      )
    end
    task_definition = Aws::ECS::Types::TaskDefinition.new(
      task_definition_arn: td["task_definition_arn"],
      container_definitions: container_definitions,
    )
    Aws::ECS::Types::DescribeTaskDefinitionResponse.new(
      task_definition: task_definition,
    )
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ufo-5.0.7 spec/lib/logs_spec.rb
ufo-5.0.6 spec/lib/logs_spec.rb
ufo-5.0.5 spec/lib/logs_spec.rb
ufo-5.0.4 spec/lib/logs_spec.rb
ufo-5.0.3 spec/lib/logs_spec.rb
ufo-5.0.2 spec/lib/logs_spec.rb
ufo-5.0.1 spec/lib/logs_spec.rb
ufo-5.0.0 spec/lib/logs_spec.rb
ufo-4.6.3 spec/lib/logs_spec.rb
ufo-4.6.2 spec/lib/logs_spec.rb
ufo-4.6.1 spec/lib/logs_spec.rb
ufo-4.6.0 spec/lib/logs_spec.rb