spec/hoosegow_docker_spec.rb in hoosegow-1.2.5 vs spec/hoosegow_docker_spec.rb in hoosegow-1.2.6

- old
+ new

@@ -1,5 +1,6 @@ +require 'fileutils' require_relative '../lib/hoosegow' unless defined?(CONFIG) begin require_relative '../config' @@ -16,34 +17,54 @@ context 'volumes' do subject { described_class.new(:volumes => volumes) } context 'unspecified' do subject { described_class.new } - its(:volumes_for_create) { should be_empty } its(:volumes_for_bind) { should be_empty } end context 'empty' do let(:volumes) { {} } - its(:volumes_for_create) { should be_empty } its(:volumes_for_bind) { should be_empty } end context 'with volumes' do let(:volumes) { { "/inside/path" => "/home/burke/data-for-container:rw", "/other/path" => "/etc/shared-config", } } - its(:volumes_for_create) { should == { - "/inside/path" => {}, - "/other/path" => {}, - } } its(:volumes_for_bind) { should == [ "/home/burke/data-for-container:/inside/path:rw", "/etc/shared-config:/other/path:ro", ] } end end + + context "volume is writable" do + it "calls after_create" do + test_dir = File.join(Dir.pwd, 'volume-test') + FileUtils.remove_dir(test_dir, true) + FileUtils.mkpath(test_dir) + + config = CONFIG.merge( + :Entrypoint => ['/usr/bin/touch', '/volume-test/test'], + :volumes => { '/volume-test' => test_dir + ":rw"} + ) + docker = Hoosegow::Docker.new(config) + begin + docker.create_container CONFIG[:image_name] + docker.start_container + ensure + docker.stop_container + docker.delete_container + end + + exists = File.exists?(File.join(test_dir, 'test')) + expect(exists).to be_truthy + FileUtils.remove_dir(test_dir, true) + end + end + context 'docker_url' do it "correctly generates TCP urls" do hoosegow = Hoosegow::Docker.new CONFIG.merge(:host => "1.1.1.1", :port => 1234) expect(::Docker.url).to eq("tcp://1.1.1.1:1234")