Sha256: fcbd69c87ecaf08b4ca8742f97f26e6b6c1b0ae35cf3b83cc5aad1ace42048dd

Contents?: true

Size: 1.73 KB

Versions: 88

Compression:

Stored size: 1.73 KB

Contents

require_relative "../../../spec_helper"
require "kontena/cli/apps/config_command"
require 'ruby_dig'

describe Kontena::Cli::Apps::ConfigCommand do
  include FixturesHelpers

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

  let(:kontena_yml) do
    fixture('mysql.yml')
  end

  let(:yaml_with_app_name) do
    {
      'version' => '2',
      'name' => 'myapp',
      'services' => {
        'mysql' => {
          'image' => '$project-mysql:5.6'
        }
      }
    }
  end

  let(:settings) do
    {'current_server' => 'alias',
     'servers' => [
         {
           'name' => 'some_master',
           'url' => 'some_master'
         }
     ]
    }
  end

  describe '#execute' do
    before(:each) do
      allow(subject).to receive(:settings).and_return(settings)
      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

    it 'outputs service configs' do
      valid_output = {
        'services' => {
          'mysql' => {
            'image' => 'mysql:5.6',
            'stateful' => false
          }
        }
      }
      expect {
        subject.run([])
      }.to output(valid_output.to_yaml).to_stdout
    end

    it 'uses app name from yaml as project variable' do

      allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(yaml_with_app_name.to_yaml)
      valid_output = {
        'services' => {
          'mysql' => {
            'image' => 'myapp-mysql:5.6',
            'stateful' => false
          }
        }
      }
      expect {
        subject.run([])
      }.to output(valid_output.to_yaml).to_stdout
    end

  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

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