Sha256: 1e22d8f5b146822a2e6cf6b025ec8fd08f6b047a7c7979e5b9670ad33a9b995e

Contents?: true

Size: 1.47 KB

Versions: 31

Compression:

Stored size: 1.47 KB

Contents

require "kontena/cli/stacks/list_command"

describe Kontena::Cli::Stacks::ListCommand do
  include ClientHelpers
  include RequirementsHelper

  expect_to_require_current_master
  expect_to_require_current_master_token

  describe '#execute' do
    it 'fetches stacks from master' do
      stacks = {
        'stacks' => []
      }
      expect(client).to receive(:get).with('grids/test-grid/stacks').and_return(stacks)
      subject.run([])
    end
  end

  describe '#build_depths' do
    it 'returns an array of hashes with "depth" field updated' do
      items = [
        {
          'depth' => 0, #stack1 1
          'name' => 'stack1_d1',
          'children' => [
            { 'name' => 'stack2_d2' },
            { 'name' => 'stack4_d2' }
          ]
        },
        {
          'depth' => 0,
          'name' => 'stack2_d2',
          'children' => [
            { 'name' => 'stack3_d3' },
          ]
        },
        {
          'depth' => 0,
          'name' => 'stack3_d3',
          'children' => []
        },
        {
          'depth' => 0,
          'name' => 'stack4_d2',
          'children' => [
            { 'name' => 'stack5_d3' }
          ]
        },
        {
          'depth' => 0,
          'name' => 'stack5_d3',
          'children' => []
        }
      ].shuffle

      subject.build_depths(items).each do |item|
        depth_expectation = item['name'].split('_d').last.to_i
        expect(item['depth']).to eq depth_expectation
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

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