2014-03-11 01:52:20 +00:00
|
|
|
require File.expand_path("../../../../../base", __FILE__)
|
|
|
|
|
|
|
|
describe "VagrantPlugins::VagrantPlugins::Cap::Rsync" do
|
2014-03-13 05:35:32 +00:00
|
|
|
let(:plugin) { VagrantPlugins::GuestSmartos::Plugin.components.guest_capabilities[:smartos].get(:rsync_pre) }
|
2014-03-11 01:52:20 +00:00
|
|
|
let(:machine) { double("machine") }
|
|
|
|
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
|
|
|
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
machine.stub(:communicate).and_return(communicator)
|
|
|
|
machine.stub(:config).and_return(config)
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
communicator.verify_expectations!
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ".rsync_installed" do
|
|
|
|
describe "when rsync is in the path" do
|
|
|
|
it "is true" do
|
|
|
|
communicator.stub_command("which rsync", stdout: '/usr/bin/rsync', exit_code: 0)
|
|
|
|
expect(plugin.rsync_installed(machine)).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when rsync is not in the path" do
|
|
|
|
it "is false" do
|
|
|
|
communicator.stub_command("which rsync", stdout: '', exit_code: 1)
|
|
|
|
expect(plugin.rsync_installed(machine)).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-13 05:35:32 +00:00
|
|
|
describe ".rsync_pre" do
|
2014-03-11 01:52:20 +00:00
|
|
|
let(:username) { "some_user" }
|
|
|
|
|
|
|
|
before do
|
|
|
|
machine.stub(:ssh_info).and_return({username: username})
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a local directory" do
|
|
|
|
communicator.expect_command(%Q(pfexec mkdir -p '/mountpoint'))
|
2014-03-13 05:35:32 +00:00
|
|
|
plugin.rsync_pre(machine, {guestpath: '/mountpoint'})
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "chowns local directory to ssh user" do
|
|
|
|
communicator.expect_command(%Q(pfexec chown -R #{username} '/mountpoint'))
|
2014-03-13 05:35:32 +00:00
|
|
|
plugin.rsync_pre(machine, {guestpath: '/mountpoint'})
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|