-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13496 from allisonlarson/allison-virtualbox-state…
…-update Update provider/virtualbox to allow paused state when booting vm
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
test/unit/vagrant/action/builtin/wait_for_communicator_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.expand_path("../../../../base", __FILE__) | ||
|
||
describe Vagrant::Action::Builtin::WaitForCommunicator do | ||
let(:app) { lambda { |env| } } | ||
let(:ui) { lambda { |env| } } | ||
let(:env) { { machine: machine, ui: ui } } | ||
|
||
let(:vm) do | ||
double("vm", | ||
communicator: nil | ||
) | ||
end | ||
|
||
# Configuration mock | ||
let(:config) { double("config", vm: vm) } | ||
|
||
# Communicate mock | ||
let(:communicate) { double("communicate") } | ||
|
||
let(:state) { double("state") } | ||
|
||
let(:ui) { Vagrant::UI::Silent.new } | ||
|
||
let(:machine) do | ||
double("machine", | ||
config: config, | ||
communicate: communicate, | ||
state: state,) | ||
end | ||
|
||
before do | ||
allow(vm).to receive(:boot_timeout).and_return(1) | ||
allow(communicate).to receive(:wait_for_ready).with(1).and_return(true) | ||
end | ||
|
||
it "raise an error if a bad state is encountered" do | ||
allow(state).to receive(:id).and_return(:stopped) | ||
|
||
expect { described_class.new(app, env, [:running]).call(env) }. | ||
to raise_error(Vagrant::Errors::VMBootBadState) | ||
end | ||
|
||
it "raise an error if the vm doesn't boot" do | ||
allow(communicate).to receive(:wait_for_ready).and_return(false) | ||
allow(state).to receive(:id).and_return(:running) | ||
|
||
expect { described_class.new(app, env, [:running]).call(env) }. | ||
to raise_error(Vagrant::Errors::VMBootTimeout) | ||
end | ||
|
||
it "succeed when a valid state is encountered" do | ||
allow(communicate).to receive(:wait_for_ready).and_return(true) | ||
allow(state).to receive(:id).and_return(:running) | ||
|
||
expect { described_class.new(app, env, [:running]).call(env) }. | ||
to_not raise_error | ||
end | ||
end |