Sha256: c61b64ea67a79124707c80ef209cc8bbbfeb79f0652ec5813bc98fafa6e20d7d

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

require 'vocker/docker_client'
require Vagrant.source_root.join('plugins/communicators/ssh/communicator')

require 'ventriloquist/service'

describe VagrantPlugins::Ventriloquist::Service do
  verify_contract(:service)

  fake(:docker_client)
  fake(:communicator) { VagrantPlugins::CommunicatorSSH::Communicator }
  let(:machine)       { fake(:machine, communicate: communicator) }

  let(:service_name) { 'dbserver' }
  let(:service_conf) { { image: 'user/dbserver', tag: 'latest' } }

  subject { described_class.new(service_name, service_conf, docker_client) }

  before { subject.provision(machine) }

  it 'runs the configured container' do
    expect(docker_client).to have_received.run_container(service_conf)
  end

  it 'creates a directory for keeping container id files' do
    expect(communicator).to have_received.sudo('mkdir -p /var/lib/ventriloquist/cids')
  end

  it 'assigns a cidfile based on the service name' do
    expected_cidfile = "#{described_class::CONTAINER_IDS_PATH}/#{service_name}"
    expect(docker_client).to have_received.run_container(with{|c| c[:cidfile] == expected_cidfile})
  end

  it 'sets dns to 127.0.0.1 to reduce latency' do
    expect(docker_client).to have_received.run_container(with{|c| c[:dns] == "127.0.0.1"})
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ventriloquist-0.1.0 spec/unit/service_spec.rb