Sha256: 6128eb8a55584283228842bbb303ef02370d2a35e7cde1a2e391fe7875db4d76

Contents?: true

Size: 1.41 KB

Versions: 22

Compression:

Stored size: 1.41 KB

Contents

require 'kontena/cli/volumes/list_command'

describe Kontena::Cli::Volumes::ListCommand do
  include ClientHelpers
  include OutputHelpers
  include RequirementsHelper

  expect_to_require_current_master
  expect_to_require_current_master_token

  mock_current_master

  let(:subject) { described_class.new("kontena") }
  let(:response)  do
    {
      'volumes' => [
        { 'id' => 'test-grid/testvol',
          'name' => 'testvol',
          'scope' => 'testscope',
          'driver' => 'testdriver',
          'created_at' => Time.parse('2001-01-01 12:00:00').to_s
        },
        { 'id' => 'test-grid/testvol2',
          'name' => 'testvol2',
          'scope' => 'testscope2',
          'driver' => 'testdriver2',
          'created_at' => Time.parse('2001-01-02 12:00:00').to_s
        }
      ]
    }
  end

  it 'lists volumes' do
    expect(client).to receive(:get).with('volumes/test-grid').and_return(response)
    expect{subject.run(['--no-long'])}.to output_table [
      ['testvol',  'testscope', 'testdriver', a_string_matching(/\d+ days ago/)],
      ['testvol2', 'testscope2', 'testdriver2', a_string_matching(/\d+ days ago/)]
    ]
  end

  context '--quiet' do
    it 'lists volume names' do
      expect(client).to receive(:get).with('volumes/test-grid').and_return(response)
      expect{subject.run(['-q'])}.to output_table([
        ['testvol'],
        ['testvol2']
      ]).without_header
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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