vagrant 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/CHANGELOG.md +48 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +49 -0
- data/README.md +2 -2
- data/Rakefile +22 -0
- data/bin/.gitignore +0 -0
- data/lib/vagrant/provisioners/chef_solo.rb +1 -1
- data/lib/vagrant/util/template_renderer.rb +2 -2
- data/lib/vagrant/version.rb +1 -1
- data/templates/Vagrantfile.erb +1 -1
- data/templates/nfs/exports.erb +4 -2
- data/test/test_helper.rb +128 -0
- data/test/vagrant/action/box/destroy_test.rb +30 -0
- data/test/vagrant/action/box/download_test.rb +141 -0
- data/test/vagrant/action/box/package_test.rb +25 -0
- data/test/vagrant/action/box/unpackage_test.rb +103 -0
- data/test/vagrant/action/box/verify_test.rb +39 -0
- data/test/vagrant/action/builder_test.rb +218 -0
- data/test/vagrant/action/env/error_halt_test.rb +21 -0
- data/test/vagrant/action/env/set_test.rb +24 -0
- data/test/vagrant/action/environment_test.rb +45 -0
- data/test/vagrant/action/exception_catcher_test.rb +30 -0
- data/test/vagrant/action/general/package_test.rb +254 -0
- data/test/vagrant/action/vm/boot_test.rb +83 -0
- data/test/vagrant/action/vm/check_box_test.rb +48 -0
- data/test/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +82 -0
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +72 -0
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +49 -0
- data/test/vagrant/action/vm/customize_test.rb +29 -0
- data/test/vagrant/action/vm/destroy_test.rb +26 -0
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +46 -0
- data/test/vagrant/action/vm/disable_networks_test.rb +39 -0
- data/test/vagrant/action/vm/discard_state_test.rb +36 -0
- data/test/vagrant/action/vm/export_test.rb +135 -0
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +70 -0
- data/test/vagrant/action/vm/forward_ports_test.rb +191 -0
- data/test/vagrant/action/vm/halt_test.rb +69 -0
- data/test/vagrant/action/vm/import_test.rb +50 -0
- data/test/vagrant/action/vm/match_mac_address_test.rb +28 -0
- data/test/vagrant/action/vm/network_test.rb +246 -0
- data/test/vagrant/action/vm/nfs_helpers_test.rb +23 -0
- data/test/vagrant/action/vm/nfs_test.rb +269 -0
- data/test/vagrant/action/vm/package_test.rb +25 -0
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/vagrant/action/vm/persist_test.rb +50 -0
- data/test/vagrant/action/vm/provision_test.rb +134 -0
- data/test/vagrant/action/vm/resume_test.rb +35 -0
- data/test/vagrant/action/vm/share_folders_test.rb +215 -0
- data/test/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/vagrant/action_test.rb +111 -0
- data/test/vagrant/active_list_test.rb +173 -0
- data/test/vagrant/box_test.rb +166 -0
- data/test/vagrant/command_test.rb +53 -0
- data/test/vagrant/commands/base_test.rb +139 -0
- data/test/vagrant/commands/box/add_test.rb +34 -0
- data/test/vagrant/commands/box/list_test.rb +32 -0
- data/test/vagrant/commands/box/remove_test.rb +41 -0
- data/test/vagrant/commands/box/repackage_test.rb +52 -0
- data/test/vagrant/commands/destroy_test.rb +44 -0
- data/test/vagrant/commands/halt_test.rb +50 -0
- data/test/vagrant/commands/init_test.rb +71 -0
- data/test/vagrant/commands/package_test.rb +97 -0
- data/test/vagrant/commands/provision_test.rb +60 -0
- data/test/vagrant/commands/reload_test.rb +47 -0
- data/test/vagrant/commands/resume_test.rb +44 -0
- data/test/vagrant/commands/ssh_config_test.rb +77 -0
- data/test/vagrant/commands/ssh_test.rb +129 -0
- data/test/vagrant/commands/status_test.rb +40 -0
- data/test/vagrant/commands/suspend_test.rb +44 -0
- data/test/vagrant/commands/up_test.rb +49 -0
- data/test/vagrant/config_test.rb +307 -0
- data/test/vagrant/downloaders/base_test.rb +28 -0
- data/test/vagrant/downloaders/file_test.rb +33 -0
- data/test/vagrant/downloaders/http_test.rb +70 -0
- data/test/vagrant/environment_test.rb +770 -0
- data/test/vagrant/hosts/base_test.rb +46 -0
- data/test/vagrant/hosts/bsd_test.rb +56 -0
- data/test/vagrant/hosts/linux_test.rb +56 -0
- data/test/vagrant/provisioners/base_test.rb +36 -0
- data/test/vagrant/provisioners/chef_server_test.rb +182 -0
- data/test/vagrant/provisioners/chef_solo_test.rb +197 -0
- data/test/vagrant/provisioners/chef_test.rb +178 -0
- data/test/vagrant/ssh_session_test.rb +46 -0
- data/test/vagrant/ssh_test.rb +317 -0
- data/test/vagrant/systems/linux_test.rb +179 -0
- data/test/vagrant/util/busy_test.rb +106 -0
- data/test/vagrant/util/plain_logger_test.rb +17 -0
- data/test/vagrant/util/platform_test.rb +18 -0
- data/test/vagrant/util/resource_logger_test.rb +145 -0
- data/test/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/vagrant/util/template_renderer_test.rb +145 -0
- data/test/vagrant/util/translator_test.rb +61 -0
- data/test/vagrant/util_test.rb +27 -0
- data/test/vagrant/vm_test.rb +228 -0
- data/vagrant.gemspec +34 -0
- metadata +158 -43
@@ -0,0 +1,52 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsBoxRepackageTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Box::Repackage
|
6
|
+
|
7
|
+
@persisted_vm = mock("persisted_vm")
|
8
|
+
@persisted_vm.stubs(:execute!)
|
9
|
+
|
10
|
+
@env = mock_environment
|
11
|
+
@env.stubs(:require_persisted_vm)
|
12
|
+
@env.stubs(:vm).returns(@persisted_vm)
|
13
|
+
|
14
|
+
@instance = @klass.new(@env)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "executing" do
|
18
|
+
setup do
|
19
|
+
@name = "foo"
|
20
|
+
end
|
21
|
+
|
22
|
+
should "show help if not enough arguments" do
|
23
|
+
Vagrant::Box.expects(:find).never
|
24
|
+
@instance.expects(:show_help).once
|
25
|
+
@instance.execute(["--include", "x,y,z"])
|
26
|
+
end
|
27
|
+
|
28
|
+
should "error and exit if the box doesn't exist" do
|
29
|
+
Vagrant::Box.expects(:find).returns(nil)
|
30
|
+
@instance.expects(:error_and_exit).with(:box_repackage_doesnt_exist).once
|
31
|
+
@instance.execute([@name])
|
32
|
+
end
|
33
|
+
|
34
|
+
should "call repackage on the box if it exists" do
|
35
|
+
@box = mock("box")
|
36
|
+
Vagrant::Box.expects(:find).with(@env, @name).returns(@box)
|
37
|
+
@box.expects(:repackage).once
|
38
|
+
@instance.execute([@name])
|
39
|
+
end
|
40
|
+
|
41
|
+
should "pass given options into repackage" do
|
42
|
+
@box = mock("box")
|
43
|
+
Vagrant::Box.expects(:find).with(@env, @name).returns(@box)
|
44
|
+
@box.expects(:repackage).once.with() do |opts|
|
45
|
+
assert opts.is_a?(Hash)
|
46
|
+
assert_equal "filename.box", opts["package.output"]
|
47
|
+
true
|
48
|
+
end
|
49
|
+
@instance.execute([@name, "--output", "filename.box"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsDestroyTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Destroy
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
|
9
|
+
@instance = @klass.new(@env)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "executing" do
|
13
|
+
should "call all or single for the method" do
|
14
|
+
@instance.expects(:all_or_single).with([], :destroy)
|
15
|
+
@instance.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "destroying a single VM" do
|
20
|
+
setup do
|
21
|
+
@foo_vm = mock("vm")
|
22
|
+
@foo_vm.stubs(:env).returns(@env)
|
23
|
+
vms = { :foo => @foo_vm }
|
24
|
+
@env.stubs(:vms).returns(vms)
|
25
|
+
end
|
26
|
+
should "error and exit if the VM doesn't exist" do
|
27
|
+
@env.stubs(:vms).returns({})
|
28
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
+
@instance.destroy_single(:foo)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "destroy if its created" do
|
33
|
+
@foo_vm.stubs(:created?).returns(true)
|
34
|
+
@foo_vm.expects(:destroy).once
|
35
|
+
@instance.destroy_single(:foo)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "do nothing if its not created" do
|
39
|
+
@foo_vm.stubs(:created?).returns(false)
|
40
|
+
@foo_vm.expects(:destroy).never
|
41
|
+
@instance.destroy_single(:foo)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsHaltTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Halt
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
@instance = @klass.new(@env)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "executing" do
|
12
|
+
should "call all or single for the method" do
|
13
|
+
@instance.expects(:all_or_single).with([], :halt)
|
14
|
+
@instance.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "halting a single VM" do
|
19
|
+
setup do
|
20
|
+
@foo_vm = mock("vm")
|
21
|
+
@foo_vm.stubs(:env).returns(@env)
|
22
|
+
vms = { :foo => @foo_vm }
|
23
|
+
@env.stubs(:vms).returns(vms)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "error and exit if the VM doesn't exist" do
|
27
|
+
@env.stubs(:vms).returns({})
|
28
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
+
@instance.halt_single(:foo)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "halt if its created" do
|
33
|
+
@foo_vm.stubs(:created?).returns(true)
|
34
|
+
@foo_vm.expects(:halt).with(:force => false).once
|
35
|
+
@instance.execute(["foo"])
|
36
|
+
end
|
37
|
+
|
38
|
+
should "halt and force if specified" do
|
39
|
+
@foo_vm.stubs(:created?).returns(true)
|
40
|
+
@foo_vm.expects(:halt).with(:force => true).once
|
41
|
+
@instance.execute(["foo", "--force"])
|
42
|
+
end
|
43
|
+
|
44
|
+
should "do nothing if its not created" do
|
45
|
+
@foo_vm.stubs(:created?).returns(false)
|
46
|
+
@foo_vm.expects(:halt).never
|
47
|
+
@instance.halt_single(:foo)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsInitTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Init
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
@instance = @klass.new(@env)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "execute" do
|
12
|
+
should "create a vagrant file without any args" do
|
13
|
+
args = []
|
14
|
+
@instance.expects(:create_vagrantfile).with(:default_box => nil, :default_box_url => nil)
|
15
|
+
@instance.execute(args)
|
16
|
+
end
|
17
|
+
context "when any arg is provided" do
|
18
|
+
should "create the vagrant file using the first arg as default_box and the second as default_box_url" do
|
19
|
+
args = []
|
20
|
+
args[0] = "foo"
|
21
|
+
args[1] = "foo.box"
|
22
|
+
|
23
|
+
@instance.expects(:create_vagrantfile).with(:default_box => "foo", :default_box_url => "foo.box")
|
24
|
+
@instance.execute(args)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "creating the vagrantfile" do
|
30
|
+
setup do
|
31
|
+
@file = mock("file")
|
32
|
+
@file.stubs(:write)
|
33
|
+
File.stubs(:open).yields(@file)
|
34
|
+
@rootfile_path = File.join(Dir.pwd, Vagrant::Environment::ROOTFILE_NAME)
|
35
|
+
|
36
|
+
Vagrant::Util::TemplateRenderer.stubs(:render)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "error and exit if a rootfile already exists" do
|
40
|
+
File.expects(:exist?).with(@rootfile_path).returns(true)
|
41
|
+
@instance.expects(:error_and_exit).with(:rootfile_already_exists).once
|
42
|
+
@instance.create_vagrantfile
|
43
|
+
end
|
44
|
+
|
45
|
+
should "write to the rootfile path using the template renderer" do
|
46
|
+
result = "foo"
|
47
|
+
Vagrant::Util::TemplateRenderer.expects(:render).returns(result).once
|
48
|
+
@file.expects(:write).with(result).once
|
49
|
+
File.expects(:open).with(@rootfile_path, 'w+').yields(@file)
|
50
|
+
|
51
|
+
@instance.create_vagrantfile
|
52
|
+
end
|
53
|
+
|
54
|
+
should "use the given base box if given" do
|
55
|
+
box = "zooo"
|
56
|
+
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => box)
|
57
|
+
@instance.create_vagrantfile :default_box => box
|
58
|
+
end
|
59
|
+
|
60
|
+
should "use the box_url if given" do
|
61
|
+
box_url = "fubar.box"
|
62
|
+
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => "fubar.box")
|
63
|
+
@instance.create_vagrantfile :default_box_url => box_url
|
64
|
+
end
|
65
|
+
|
66
|
+
should "use the default `base` if no box is given" do
|
67
|
+
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base")
|
68
|
+
@instance.create_vagrantfile
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsPackageTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Package
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
@instance = @klass.new(@env)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "executing" do
|
12
|
+
should "package base if a base is given" do
|
13
|
+
@instance.expects(:package_base).once
|
14
|
+
@instance.execute(["--base","foo"])
|
15
|
+
end
|
16
|
+
|
17
|
+
should "package single if no name is given" do
|
18
|
+
@instance.expects(:package_single).with(nil).once
|
19
|
+
@instance.execute
|
20
|
+
end
|
21
|
+
|
22
|
+
should "package single if a name is given" do
|
23
|
+
@instance.expects(:package_single).with("foo").once
|
24
|
+
@instance.execute(["foo"])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "packaging base" do
|
29
|
+
should "error and exit if no VM is found" do
|
30
|
+
Vagrant::VM.expects(:find).with("foo", @instance.env).returns(nil)
|
31
|
+
@instance.expects(:error_and_exit).with(:vm_base_not_found, :name => "foo").once
|
32
|
+
@instance.execute(["--base", "foo"])
|
33
|
+
end
|
34
|
+
|
35
|
+
should "package the VM like any other VM" do
|
36
|
+
vm = mock("vm")
|
37
|
+
Vagrant::VM.expects(:find).with("foo", @instance.env).returns(vm)
|
38
|
+
@instance.expects(:package_vm).with(vm).once
|
39
|
+
@instance.execute(["--base", "foo"])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "packaging a single VM" do
|
44
|
+
setup do
|
45
|
+
@vm = mock("vm")
|
46
|
+
@vm.stubs(:created?).returns(true)
|
47
|
+
|
48
|
+
@vms = {:bar => @vm}
|
49
|
+
@env.stubs(:vms).returns(@vms)
|
50
|
+
@env.stubs(:multivm?).returns(false)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "error and exit if no name is given in a multi-vm env" do
|
54
|
+
@env.stubs(:multivm?).returns(true)
|
55
|
+
@instance.expects(:error_and_exit).with(:package_multivm).once
|
56
|
+
@instance.package_single(nil)
|
57
|
+
end
|
58
|
+
|
59
|
+
should "error and exit if the VM doesn't exist" do
|
60
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
61
|
+
@instance.package_single(:foo)
|
62
|
+
end
|
63
|
+
|
64
|
+
should "error and exit if the VM is not created" do
|
65
|
+
@vm.stubs(:created?).returns(false)
|
66
|
+
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
67
|
+
@instance.package_single(:bar)
|
68
|
+
end
|
69
|
+
|
70
|
+
should "use the first VM is no name is given in a single VM environment" do
|
71
|
+
@instance.expects(:package_vm).with(@vm).once
|
72
|
+
@instance.package_single(nil)
|
73
|
+
end
|
74
|
+
|
75
|
+
should "package the VM" do
|
76
|
+
@instance.expects(:package_vm).with(@vm).once
|
77
|
+
@instance.package_single(:bar)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "packaging a VM" do
|
82
|
+
setup do
|
83
|
+
@vm = mock("vm")
|
84
|
+
|
85
|
+
@options = {}
|
86
|
+
@instance.stubs(:options).returns(@options)
|
87
|
+
end
|
88
|
+
|
89
|
+
should "package the VM with the proper arguments" do
|
90
|
+
@options[:output] = "foo.box"
|
91
|
+
@options[:include] = :bar
|
92
|
+
|
93
|
+
@vm.expects(:package).with(@options).once
|
94
|
+
@instance.package_vm(@vm)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsProvisionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Provision
|
6
|
+
@env = mock_environment
|
7
|
+
@instance = @klass.new(@env)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "executing" do
|
11
|
+
should "provision all if no name is given" do
|
12
|
+
@instance.expects(:all_or_single).with([], :provision).once
|
13
|
+
@instance.execute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "provisioning a single VM" do
|
18
|
+
setup do
|
19
|
+
@foo_vm = mock("vm")
|
20
|
+
@foo_vm.stubs(:env).returns(@env)
|
21
|
+
@foo_vm.stubs(:created?).returns(true)
|
22
|
+
|
23
|
+
@vm_for_real = mock("vm for real")
|
24
|
+
@foo_vm.stubs(:vm).returns(@vm_for_real)
|
25
|
+
vms = { :foo => @foo_vm }
|
26
|
+
@env.stubs(:vms).returns(vms)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "error and exit if the VM doesn't exist" do
|
30
|
+
@env.stubs(:vms).returns({})
|
31
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => 'foo').once
|
32
|
+
@instance.execute(["foo"])
|
33
|
+
end
|
34
|
+
|
35
|
+
should "reload if it's running" do
|
36
|
+
@vm_for_real.stubs(:running?).returns(true)
|
37
|
+
@foo_vm.expects(:provision).once
|
38
|
+
@instance.execute(["foo"])
|
39
|
+
end
|
40
|
+
|
41
|
+
should "do log to info if it's not running" do
|
42
|
+
logger = mock("logger")
|
43
|
+
logger.expects(:info)
|
44
|
+
@env.stubs(:logger).returns(logger)
|
45
|
+
@vm_for_real.stubs(:running?).returns(false)
|
46
|
+
@foo_vm.expects(:provision).never
|
47
|
+
@instance.execute(["foo"])
|
48
|
+
end
|
49
|
+
|
50
|
+
should "do log to info if it's not created" do
|
51
|
+
logger = mock("logger")
|
52
|
+
logger.expects(:info)
|
53
|
+
@env.stubs(:logger).returns(logger)
|
54
|
+
@foo_vm.stubs(:created?).returns(false)
|
55
|
+
@foo_vm.expects(:provision).never
|
56
|
+
@instance.execute(["foo"])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsReloadTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Reload
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
@env.stubs(:require_root_path)
|
9
|
+
@instance = @klass.new(@env)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "executing" do
|
13
|
+
should "call all or single for the method" do
|
14
|
+
seq = sequence("seq")
|
15
|
+
@env.expects(:require_root_path).in_sequence(seq)
|
16
|
+
@instance.expects(:all_or_single).with([], :reload).in_sequence(seq)
|
17
|
+
@instance.execute
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "reloading a single VM" do
|
22
|
+
setup do
|
23
|
+
@foo_vm = mock("vm")
|
24
|
+
@foo_vm.stubs(:env).returns(@env)
|
25
|
+
vms = { :foo => @foo_vm }
|
26
|
+
@env.stubs(:vms).returns(vms)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "error and exit if the VM doesn't exist" do
|
30
|
+
@env.stubs(:vms).returns({})
|
31
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
32
|
+
@instance.reload_single(:foo)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "reload if its created" do
|
36
|
+
@foo_vm.stubs(:created?).returns(true)
|
37
|
+
@foo_vm.expects(:reload).once
|
38
|
+
@instance.execute(["foo"])
|
39
|
+
end
|
40
|
+
|
41
|
+
should "do nothing if its not created" do
|
42
|
+
@foo_vm.stubs(:created?).returns(false)
|
43
|
+
@foo_vm.expects(:reload).never
|
44
|
+
@instance.reload_single(:foo)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandsResumeTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Commands::Resume
|
6
|
+
|
7
|
+
@env = mock_environment
|
8
|
+
@instance = @klass.new(@env)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "executing" do
|
12
|
+
should "call all or single for the method" do
|
13
|
+
@instance.expects(:all_or_single).with([], :resume)
|
14
|
+
@instance.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "resuming a single VM" do
|
19
|
+
setup do
|
20
|
+
@foo_vm = mock("vm")
|
21
|
+
@foo_vm.stubs(:env).returns(@env)
|
22
|
+
vms = { :foo => @foo_vm }
|
23
|
+
@env.stubs(:vms).returns(vms)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "error and exit if the VM doesn't exist" do
|
27
|
+
@env.stubs(:vms).returns({})
|
28
|
+
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
+
@instance.resume_single(:foo)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "resume if its created" do
|
33
|
+
@foo_vm.stubs(:created?).returns(true)
|
34
|
+
@foo_vm.expects(:resume).once
|
35
|
+
@instance.execute(["foo"])
|
36
|
+
end
|
37
|
+
|
38
|
+
should "do nothing if its not created" do
|
39
|
+
@foo_vm.stubs(:created?).returns(false)
|
40
|
+
@foo_vm.expects(:resume).never
|
41
|
+
@instance.resume_single(:foo)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|