Sha256: bf791597d9fa01ea532474049fba04d72e3c661b94d94a2cd72e8550959ba239

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 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 }
  fake(:ui)           { Vagrant::UI::Interface }
  let(:env)           { fake(:environment, ui: ui) }
  let(:machine)       { fake(:machine, communicate: communicator, env: env) }

  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

5 entries across 5 versions & 1 rubygems

Version Path
ventriloquist-0.3.2 spec/unit/service_spec.rb
ventriloquist-0.3.1 spec/unit/service_spec.rb
ventriloquist-0.3.0 spec/unit/service_spec.rb
ventriloquist-0.2.1 spec/unit/service_spec.rb
ventriloquist-0.2.0 spec/unit/service_spec.rb