2016-06-06 16:22:03 +00:00
|
|
|
require_relative "../../../../base"
|
2014-03-11 01:52:20 +00:00
|
|
|
|
|
|
|
describe "VagrantPlugins::VagrantPlugins::Cap::Rsync" do
|
2014-04-25 19:00:12 +00:00
|
|
|
let(:plugin) { VagrantPlugins::GuestSmartos::Plugin.components.guest_capabilities[:smartos].get(:rsync_installed) }
|
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
|
2017-08-04 17:10:58 +00:00
|
|
|
allow(machine).to receive(:communicate).and_return(communicator)
|
|
|
|
allow(machine).to receive(:config).and_return(config)
|
2014-03-11 01:52:20 +00:00
|
|
|
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-07-31 21:41:06 +00:00
|
|
|
|
|
|
|
describe ".rsync_pre" do
|
|
|
|
it 'makes the guestpath directory with pfexec' do
|
|
|
|
communicator.expect_command("pfexec mkdir -p '/sync_dir'")
|
|
|
|
plugin.rsync_pre(machine, guestpath: '/sync_dir')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ".rsync_post" do
|
|
|
|
it 'chowns incorrectly owned files in sync dir' do
|
2016-08-16 22:08:57 +00:00
|
|
|
communicator.expect_command("pfexec find /sync_dir '!' -type l -a '(' ! -user somebody -or ! -group somegroup ')' -exec chown somebody:somegroup '{}' +")
|
2014-07-31 21:41:06 +00:00
|
|
|
plugin.rsync_post(machine, guestpath: '/sync_dir', owner: 'somebody', group: 'somegroup')
|
|
|
|
end
|
|
|
|
end
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|