Sha256: 37a85cc13f6a2d5d0085d06914fb6fa36533a8a25bf6e1771e3476fce558e61a

Contents?: true

Size: 1.88 KB

Versions: 89

Compression:

Stored size: 1.88 KB

Contents

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

describe Kontena::Cli::Apps::ServiceGeneratorV2 do
  let(:subject) do
    described_class.new({})
  end

  describe '#parse_data' do
    it 'parses network_mode' do
      data = {
        'image' => 'wordpress:latest',
        'network_mode' => 'bridge'
      }
      result = subject.send(:parse_data, data)
      expect(result['net']).to eq('bridge')
    end

    it 'parses logging' do
      data = {
        'image' => 'wordpress:latest',
        'logging' => {
          'driver' => 'influxdb',
          'options' => {
            'syslog-address' => 'tcp://192.168.0.42:123'
          }
        }
      }
      result = subject.send(:parse_data, data)
      expect(result['log_driver']).to eq('influxdb')
      expect(result['log_opts']).to eq({
        'syslog-address' => 'tcp://192.168.0.42:123'
      })
    end

    it 'adds depends_on to links' do
      data = {
        'image' => 'wordpress:latest',
        'depends_on' => ['mysql']
      }
      result = subject.send(:parse_data, data)
      expect(result['links']).to eq([{
        'name' => 'mysql',
        'alias' => 'mysql'
      }])
    end
  end

  describe '#parse_build_options' do
    context 'when build option is a string' do
      it 'converts build option to hash' do
        data = {
          'build' => '.',
          'image' => 'myapp'
        }
        result = subject.send(:parse_build_options, data)
        expect(result).to eq({ 'context' => '.' })
      end
    end
    context 'when build options is a hash' do
      it 'uses it as build options' do
        data = {
          'build' => {
            'context' => '.',
            'dockerfile' => 'alternate-dockerfile'
           }
        }
        result = subject.send(:parse_build_options, data)
        expect(result).to eq(data['build'])
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

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