2016-06-06 16:22:03 +00:00
|
|
|
require_relative "../../../../base"
|
2014-03-11 01:52:20 +00:00
|
|
|
|
2016-08-03 18:34:03 +00:00
|
|
|
describe "VagrantPlugins::GuestSmartos::Cap::Halt" do
|
2014-03-11 01:52:20 +00:00
|
|
|
let(:plugin) { VagrantPlugins::GuestSmartos::Plugin.components.guest_capabilities[:smartos].get(:halt) }
|
|
|
|
let(:machine) { double("machine") }
|
2016-08-03 18:34:03 +00:00
|
|
|
let(:config) { double("config", smartos: double("smartos", suexec_cmd: 'pfexec')) }
|
2014-03-11 01:52:20 +00:00
|
|
|
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
2017-05-24 17:29:46 +00:00
|
|
|
let(:shutdown_command){ "pfexec /usr/sbin/poweroff" }
|
2014-03-11 01:52:20 +00:00
|
|
|
|
|
|
|
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 ".halt" do
|
|
|
|
it "sends a shutdown signal" do
|
2016-08-03 18:34:03 +00:00
|
|
|
communicator.expect_command(shutdown_command)
|
2014-03-11 01:52:20 +00:00
|
|
|
plugin.halt(machine)
|
|
|
|
end
|
2016-08-03 18:34:03 +00:00
|
|
|
|
|
|
|
it "ignores an IOError" do
|
|
|
|
communicator.stub_command(shutdown_command, raise: IOError)
|
|
|
|
expect {
|
|
|
|
plugin.halt(machine)
|
|
|
|
}.to_not raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it "ignores a Vagrant::Errors::SSHDisconnected" do
|
|
|
|
communicator.stub_command(shutdown_command, raise: Vagrant::Errors::SSHDisconnected)
|
|
|
|
expect {
|
|
|
|
plugin.halt(machine)
|
|
|
|
}.to_not raise_error
|
|
|
|
end
|
2014-03-11 01:52:20 +00:00
|
|
|
end
|
|
|
|
end
|