Reload action only halts the machine if its running
This commit is contained in:
parent
06ff3a363c
commit
41b25e68ec
|
@ -3,7 +3,8 @@ module Vagrant
|
|||
module VM
|
||||
class Reload < Base
|
||||
def prepare
|
||||
steps = [Halt, ForwardPorts, SharedFolders, Start]
|
||||
steps = [ForwardPorts, SharedFolders, Start]
|
||||
steps.unshift(Halt) if @runner.vm.running?
|
||||
steps << Provision if Vagrant.config.chef.enabled
|
||||
|
||||
steps.each do |action_klass|
|
||||
|
|
|
@ -2,19 +2,20 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
|||
|
||||
class ReloadActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Reload)
|
||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Reload)
|
||||
mock_config
|
||||
end
|
||||
|
||||
context "sub-actions" do
|
||||
setup do
|
||||
@default_order = [Vagrant::Actions::VM::Halt, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
|
||||
@default_order = [Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
|
||||
@vm.stubs(:running?).returns(false)
|
||||
end
|
||||
|
||||
def setup_action_expectations
|
||||
default_seq = sequence("default_seq")
|
||||
@default_order.each do |action|
|
||||
@mock_vm.expects(:add_action).with(action).once.in_sequence(default_seq)
|
||||
@runner.expects(:add_action).with(action).once.in_sequence(default_seq)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,6 +24,13 @@ class ReloadActionTest < Test::Unit::TestCase
|
|||
@action.prepare
|
||||
end
|
||||
|
||||
should "halt if the VM is running" do
|
||||
@vm.expects(:running?).returns(true)
|
||||
@default_order.unshift(Vagrant::Actions::VM::Halt)
|
||||
setup_action_expectations
|
||||
@action.prepare
|
||||
end
|
||||
|
||||
should "add in the provisioning step if enabled" do
|
||||
mock_config do |config|
|
||||
config.chef.enabled = true
|
||||
|
|
Loading…
Reference in New Issue