2016-06-06 16:22:03 +00:00
|
|
|
require_relative "../../../../base"
|
2017-06-16 20:58:07 +00:00
|
|
|
require_relative "../../../../../../plugins/guests/smartos/config"
|
|
|
|
|
|
|
|
describe "VagrantPlugins::GuestSmartos::Cap::MountNFS" do
|
|
|
|
let(:caps) do
|
|
|
|
VagrantPlugins::GuestSmartos::Plugin
|
|
|
|
.components
|
|
|
|
.guest_capabilities[:smartos]
|
|
|
|
end
|
2014-03-11 01:52:20 +00:00
|
|
|
|
|
|
|
let(:machine) { double("machine") }
|
2017-06-16 20:58:07 +00:00
|
|
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
2014-03-11 01:52:20 +00:00
|
|
|
let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
|
|
|
|
|
|
|
|
before do
|
2017-08-04 17:10:58 +00:00
|
|
|
allow(machine).to receive(:communicate).and_return(comm)
|
|
|
|
allow(machine).to receive(:config).and_return(config)
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2017-06-16 20:58:07 +00:00
|
|
|
comm.verify_expectations!
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe ".mount_nfs_folder" do
|
2017-06-16 20:58:07 +00:00
|
|
|
let(:cap) { caps.get(:mount_nfs_folder) }
|
2014-03-11 01:52:20 +00:00
|
|
|
|
2017-06-16 20:58:07 +00:00
|
|
|
it "mounts the folder" do
|
|
|
|
cap.mount_nfs_folder(machine, '1.1.1.1', {'nfs' => {guestpath: '/mountpoint', hostpath: '/some/share'}})
|
|
|
|
|
|
|
|
expect(comm.received_commands[0]).to match(/if \[ -d \/usbkey \] && \[ "\$\(zonename\)" == "global" \] ; then/)
|
|
|
|
expect(comm.received_commands[0]).to match(/pfexec mkdir -p \/usbkey\/config.inc/)
|
|
|
|
expect(comm.received_commands[0]).to match(/printf '1\.1\.1\.1:\/some\/share:\/mountpoint' | pfexec tee -a \/usbkey\/config.inc\/nfs_mounts/)
|
|
|
|
expect(comm.received_commands[0]).to match(/fi/)
|
|
|
|
expect(comm.received_commands[0]).to match(/pfexec mkdir -p \/mountpoint/)
|
|
|
|
expect(comm.received_commands[0]).to match(/pfexec \/usr\/sbin\/mount -F nfs '1\.1\.1\.1:\/some\/share' '\/mountpoint'/)
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|