Sha256: 12303052834a1ba40cba01d33f572526bd9c8f2d64f91880da9f57ad889789ee

Contents?: true

Size: 1.61 KB

Versions: 39

Compression:

Stored size: 1.61 KB

Contents

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

describe Kontena::Cli::Stacks::RemoveCommand do

  include ClientHelpers

  describe '#execute' do
    it 'requires api url' do
      allow(subject).to receive(:forced?).and_return(true)
      allow(subject).to receive(:wait_stack_removal)
      expect(described_class.requires_current_master?).to be_truthy
      subject.run(['test-stack'])
    end

    it 'requires token' do
      allow(subject).to receive(:forced?).and_return(true)
      allow(subject).to receive(:wait_stack_removal)
      expect(described_class.requires_current_master_token?).to be_truthy
      subject.run(['test-stack'])
    end

    it 'sends remove command to master' do
      allow(subject).to receive(:wait_stack_removal)
      expect(client).to receive(:delete).with('stacks/test-grid/test-stack')
      subject.run(['--force', 'test-stack'])
    end

    it 'waits until service is removed' do
      allow(client).to receive(:delete).with('stacks/test-grid/test-stack')
      expect(client).to receive(:get).with('stacks/test-grid/test-stack')
        .and_raise(Kontena::Errors::StandardError.new(404, 'Not Found'))
      subject.run(['--force', 'test-stack'])
    end

    it 'raises exception on server error' do
      expect(client).to receive(:delete).with('stacks/test-grid/test-stack')
      expect(client).to receive(:get).with('stacks/test-grid/test-stack')
        .and_raise(Kontena::Errors::StandardError.new(500, 'internal error'))
      expect{
        subject.run(['--force', 'test-stack'])
      }.to raise_error(Kontena::Errors::StandardError)
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
kontena-cli-1.1.6 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.5 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.5.rc3 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.5.rc2 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.5.rc1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.4 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.3 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.2 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.2.rc2 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.2.rc1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.1.rc1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.0 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.0.rc2 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.0.rc1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.1.0.pre1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.0.6 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.0.6.rc1 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.0.5 spec/kontena/cli/stacks/remove_command_spec.rb
kontena-cli-1.0.5.rc1 spec/kontena/cli/stacks/remove_command_spec.rb