Sha256: 1fca141314f9b4e3dee04782a11f1fa7a769680c101f6017c1239bf71bb86c79

Contents?: true

Size: 1.54 KB

Versions: 27

Compression:

Stored size: 1.54 KB

Contents

require "kontena/cli/containers/logs_command"

describe Kontena::Cli::Containers::LogsCommand do
  include ClientHelpers

  context "for a single container with logs" do
    let(:logs) do
      [
        {
          'id' => '57cff2e8cfee65c8b6efc8bd',
          'name' => 'test-mysql-1',
          'created_at' => '2016-09-07T15:19:04.362690',
          'data' => "mysql log message 1",
        },
        {
          'id' => '57cff2e8cfee65c8b6efc8be',
          'name' => 'test-mysql-1',
          'created_at' => '2016-09-07T15:19:04.500000',
          'data' => "mysql log message 2",
        },
        {
          'id' => '57cff2e8cfee65c8b6efc8c1',
          'name' => 'test-mysql-1',
          'created_at' => '2016-09-07T15:19:06.100000',
          'data' => "mysql log message 3",
        },
      ]
    end

    before(:each) do
      Kontena.pastel.resolver.color.disable!
    end

    it "shows all logs" do
      allow(client).to receive(:get).with('containers/test-grid/node-1/test-mysql-1/logs', {
        limit: 100,
      }) { { 'logs' => logs } }

      expect { subject.run(['node-1/test-mysql-1']) }.to output(<<LOGS
2016-09-07T15:19:04.362690 test-mysql-1: mysql log message 1
2016-09-07T15:19:04.500000 test-mysql-1: mysql log message 2
2016-09-07T15:19:06.100000 test-mysql-1: mysql log message 3
LOGS
      ).to_stdout
    end

    it "errors for an invalid --lines" do
      expect { subject.run(["--lines=invalid", "node-1/test-mysql-1"]) }.to raise_error(Clamp::UsageError, "option '--lines': invalid value for Integer(): \"invalid\"")
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
kontena-cli-1.3.5 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.5.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.4 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.4.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.3 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.3.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.2 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.2.rc2 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.2.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.1.rc2 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.1.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.rc4 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.rc3 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.rc2 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.rc1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.pre2 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.3.0.pre1 spec/kontena/cli/containers/logs_command_spec.rb
kontena-cli-1.2.2 spec/kontena/cli/containers/logs_command_spec.rb