Sha256: 0c035170cc9e73ae3ecae4d71cf8d6e864358709439d4fee34ded587a915b6ca

Contents?: true

Size: 1.46 KB

Versions: 36

Compression:

Stored size: 1.46 KB

Contents

require 'kontena/cli/containers/exec_command'

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

  it 'executes with defaults' do
    expect(subject).to receive(:container_exec).with('test-grid/host/test-service-1', [ 'test' ],
      interactive: false,
      shell: false,
      tty: false,
    ) { 0 }

    subject.run(['host/test-service-1', 'test'])
  end

  it 'executes with --shell' do
    expect(subject).to receive(:container_exec).with('test-grid/host/test-service-1', [ 'echo', '$HOSTNAME' ],
      interactive: false,
      shell: true,
      tty: false,
    ) { 0 }

    subject.run(['--shell', 'host/test-service-1', 'echo', '$HOSTNAME'])
  end

  it 'executes with -i' do
    expect(subject).to receive(:container_exec).with('test-grid/host/test-service-1', [ 'test' ],
      interactive: true,
      shell: false,
      tty: false,
    ) { 0 }

    subject.run(['-i', 'host/test-service-1', 'test'])
  end

  it 'executes with -it' do
    expect(subject).to receive(:container_exec).with('test-grid/host/test-service-1', [ 'test' ],
      interactive: true,
      shell: false,
      tty: true,
    ) { 0 }

    subject.run(['-it', 'host/test-service-1', 'test'])
  end

  it 'fails on error' do
    expect(subject).to receive(:container_exec).with('test-grid/host/test-service-1', [ 'test' ],
      interactive: false,
      shell: false,
      tty: false,
    ) { 1 }

    expect{subject.run(['host/test-service-1', 'test'])}.to exit_with_error
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
kontena-cli-1.5.4 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.4.rc1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.3 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.2 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.rc1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.pre5 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.pre4 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.pre3 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.pre2 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.5.0.pre1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.3 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.3.rc1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.2 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.2.rc1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.2.pre1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.1.rc1 spec/kontena/cli/containers/exec_command_spec.rb
kontena-cli-1.4.1.pre1 spec/kontena/cli/containers/exec_command_spec.rb