Sha256: 46b1aeda97beb5fb04a95d9642c54aca78dadf187f8e5180503fef57984188f3

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Vx::Lib::Container::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_lib_container_#{Process.pid}")
    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 |sh|
        rs = sh.id
      end
      expect(rs).to be
    end

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

        conn.start do |sh|
          code = sh.exec("pwd") do |out|
            rs << out
          end
        end

        dir = "#{Dir.tmpdir}/vx_lib_container_#{Process.pid}\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 |sh|
          code = sh.exec('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

9 entries across 9 versions & 1 rubygems

Version Path
vx-lib-container-0.6.3 spec/lib/local_spec.rb
vx-lib-container-0.6.2 spec/lib/local_spec.rb
vx-lib-container-0.6.1 spec/lib/local_spec.rb
vx-lib-container-0.6.0 spec/lib/local_spec.rb
vx-lib-container-0.5.11 spec/lib/local_spec.rb
vx-lib-container-0.5.10 spec/lib/local_spec.rb
vx-lib-container-0.5.9 spec/lib/local_spec.rb
vx-lib-container-0.5.8 spec/lib/local_spec.rb
vx-lib-container-0.5.7 spec/lib/local_spec.rb