Sha256: 28ecac45b3a6dceb6d3ddb8f75498ce1dbde6fb46f4db37d3357e434eada1930

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require_relative "../../../spec_helper"
require "kontena/cli/services/remove_secret_command"

describe Kontena::Cli::Services::RemoveSecretCommand do

  include ClientHelpers

  describe '#execute' do
    it 'requires api url' do
      expect(subject).to receive(:require_api_url).once
      subject.run(['service', 'secret:name:env'])
    end

    it 'requires token' do
      expect(subject).to receive(:require_token).and_return(token)
      subject.run(['service', 'secret:name:env'])
    end

    it 'requires service as param' do
      expect {
        subject.run([])
      }.to raise_error(Clamp::UsageError)
    end

    it 'requires secret as param' do
      expect {
        subject.run(['service'])
      }.to raise_error(Clamp::UsageError)
    end

    it 'removes secret to existing list' do
      original = {
        'secrets' => [
          {'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'},
          {'secret' => 'BAR', 'name' => 'BAZ', 'type' => 'env'}
        ]
      }
      data = {
        secrets: [
          {'secret' => 'BAR', 'name' => 'BAZ', 'type' => 'env'}
        ]
      }
      allow(client).to receive(:get).with("services/test-grid/mymy").and_return(original)
      expect(client).to receive(:put).with("services/test-grid/mymy", data)
      subject.run(['mymy', 'FOO:BAR:env'])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kontena-cli-0.12.3 spec/kontena/cli/services/remove_secret_command_spec.rb
kontena-cli-0.12.2 spec/kontena/cli/services/remove_secret_command_spec.rb
kontena-cli-0.12.1 spec/kontena/cli/services/remove_secret_command_spec.rb
kontena-cli-0.12.0 spec/kontena/cli/services/remove_secret_command_spec.rb