Sha256: 663fc3fc79543cf346b8d4c9f4a76e3d7e5d21df386fdbd1742334d01dea5291

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe Vx::ContainerConnector::Local do
  let(:conn) { described_class.new }
  subject { conn }

  it { should be }

  context "work_dir" do
    it "by default should be inside Dir.tmpdir" do
      expect(conn.work_dir).to eq("#{Dir.tmpdir}/.vx_local_connector")
    end

    it "when passed via options, should be" do
      expect(described_class.new(work_dir: "/tmp").work_dir).to eq '/tmp'
    end
  end

  context "start container" do

    it "spawner id should eq local" do
      rs = nil
      conn.start do |spawner|
        rs = spawner.id
      end
      expect(rs).to eq 'local'
    end

    context "and spawn script" do
      it "successfuly" do
        rs   = ""
        code = nil

        conn.start do |spawner|
          code = spawner.spawn("echo $PWD") do |out|
            rs << out
          end
        end

        dir = "#{Dir.tmpdir}/.vx_local_connector\n"
        if RUBY_PLATFORM =~ /darwin/
          dir.gsub!(/^\/var/, '/private/var')
        end

        expect(rs).to eq dir
        expect(code).to eq 0
      end

      it "failed" do
        code = nil
        rs   = ""
        conn.start do |spawner|
          code = spawner.spawn('ls /notexists') do |out|
            rs << out
          end
        end

        expect(rs).to match(/No such file or directory/)
        expect([1,2]).to be_include(code)
      end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
vx-container_connector-0.5.7 spec/lib/local_spec.rb
vx-container_connector-0.5.6 spec/lib/local_spec.rb
vx-container_connector-0.5.5 spec/lib/local_spec.rb
vx-container_connector-0.5.4 spec/lib/local_spec.rb
vx-container_connector-0.5.3 spec/lib/local_spec.rb
vx-container_connector-0.5.2 spec/lib/local_spec.rb
vx-container_connector-0.5.1 spec/lib/local_spec.rb
vx-container_connector-0.5.0 spec/lib/local_spec.rb
vx-container_connector-0.4.3 spec/lib/local_spec.rb
vx-container_connector-0.4.2 spec/lib/local_spec.rb
vx-container_connector-0.4.1 spec/lib/local_spec.rb
vx-container_connector-0.4.0 spec/lib/local_spec.rb
vx-container_connector-0.3.1 spec/lib/local_spec.rb
vx-container_connector-0.3.0 spec/lib/local_spec.rb