Sha256: 5db6a34f5e126028990431626c90ac326b3b997354313ad79e6fd6fd1e6859ce

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 KB

Contents

require_relative "../../../spec_helper"
require "kontena/cli/stacks/upgrade_command"

describe Kontena::Cli::Stacks::UpgradeCommand do

  include ClientHelpers

  describe '#execute' do

    let(:stack) do
      {
        'name' => 'stack-a',
        'services' => []
      }
    end

    it 'requires api url' do
      allow(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
      expect(subject).to receive(:require_api_url).once
      subject.run(['stack-name', './path/to/kontena.yml'])
    end

    it 'requires token' do
      allow(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
      expect(subject).to receive(:require_token).and_return(token)
      subject.run(['stack-name', './path/to/kontena.yml'])
    end

    it 'sends stack to master' do
      
      allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
      allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml').and_return(stack)
      expect(client).to receive(:put).with(
        'stacks/test-grid/stack-a', anything
      )
      subject.run(['stack-a', './path/to/kontena.yml'])
    end

    it 'allows to override stack name' do
      allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
      allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml').and_return(stack)
      stack_b = stack
      stack_b[:name] = 'stack-b'
      expect(client).to receive(:put).with(
        'stacks/test-grid/stack-b', anything
      )
      subject.run(['stack-b',  './path/to/kontena.yml'])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-cli-0.17.0.pre5 spec/kontena/cli/stacks/upgrade_command_spec.rb
kontena-cli-0.17.0.pre4 spec/kontena/cli/stacks/upgrade_command_spec.rb
kontena-cli-0.17.0.pre3 spec/kontena/cli/stacks/upgrade_command_spec.rb
kontena-cli-0.17.0.pre2 spec/kontena/cli/stacks/upgrade_command_spec.rb
kontena-cli-0.17.0.pre1 spec/kontena/cli/stacks/upgrade_command_spec.rb