Sha256: 7f556115544a0a5f33916aa0eaf370387dd52190db8fdf6999770b053ed0bf00

Contents?: true

Size: 1.31 KB

Versions: 32

Compression:

Stored size: 1.31 KB

Contents

require_relative "../../../spec_helper"
require "kontena/cli/apps/scale_command"

describe Kontena::Cli::Apps::ScaleCommand do
  include FixturesHelpers
  include ClientHelpers

  let(:subject) do
    described_class.new(File.basename($0))
  end

  let(:kontena_yml) do
    fixture('wordpress-scaled.yml')
  end

  let(:kontena_yml_no_instances) do
    fixture('wordpress.yml')
  end

  describe '#execute' do
    before(:each) do
      allow(subject).to receive(:current_dir).and_return("kontena-test")
      allow(File).to receive(:exists?).and_return(true)
      allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
    end

    context 'when service already contains instances property' do
      it 'aborts execution' do
        expect{
          subject.run(['wordpress', 3])
        }.to raise_error(SystemExit)
      end
    end

    context 'when service not found in YML' do
      it 'aborts execution' do
        expect{
          subject.run(['mysql', 3])
        }.to raise_error(SystemExit)
      end
    end

    it 'scales given service' do
      allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml_no_instances)
      expect(subject).to receive(:scale_service).with('1234567','kontena-test-wordpress',3)
      subject.run(['wordpress', 3])
    end

  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.5.rc2 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.5.rc1 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.4 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.4.rc2 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.4.rc1 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.4.pre1 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.3 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.2 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.1 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.0 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.0.rc3 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.0.rc2 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.15.0.rc1 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.7 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.6 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.5 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.4 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.3 spec/kontena/cli/app/scale_spec.rb
kontena-cli-0.14.2 spec/kontena/cli/app/scale_spec.rb