vagrantup 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +56 -0
- data/Gemfile +14 -3
- data/Gemfile.lock +38 -11
- data/README.md +1 -1
- data/bin/vagrant +20 -5
- data/config/default.rb +6 -8
- data/lib/vagrant.rb +40 -13
- data/lib/vagrant/action.rb +56 -16
- data/lib/vagrant/action/box/destroy.rb +3 -1
- data/lib/vagrant/action/box/download.rb +8 -13
- data/lib/vagrant/action/box/unpackage.rb +8 -11
- data/lib/vagrant/action/box/verify.rb +3 -3
- data/lib/vagrant/action/builder.rb +3 -30
- data/lib/vagrant/action/builtin.rb +6 -1
- data/lib/vagrant/action/environment.rb +14 -62
- data/lib/vagrant/action/general/package.rb +29 -22
- data/lib/vagrant/action/vm/boot.rb +5 -12
- data/lib/vagrant/action/vm/check_box.rb +4 -4
- data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
- data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
- data/lib/vagrant/action/vm/customize.rb +1 -1
- data/lib/vagrant/action/vm/destroy.rb +1 -2
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
- data/lib/vagrant/action/vm/disable_networks.rb +11 -9
- data/lib/vagrant/action/vm/discard_state.rb +2 -2
- data/lib/vagrant/action/vm/export.rb +10 -11
- data/lib/vagrant/action/vm/forward_ports.rb +21 -9
- data/lib/vagrant/action/vm/halt.rb +3 -8
- data/lib/vagrant/action/vm/import.rb +16 -14
- data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
- data/lib/vagrant/action/vm/network.rb +9 -16
- data/lib/vagrant/action/vm/nfs.rb +14 -18
- data/lib/vagrant/action/vm/provision.rb +5 -5
- data/lib/vagrant/action/vm/resume.rb +1 -1
- data/lib/vagrant/action/vm/share_folders.rb +6 -44
- data/lib/vagrant/action/vm/suspend.rb +1 -1
- data/lib/vagrant/action/warden.rb +74 -0
- data/lib/vagrant/box.rb +18 -82
- data/lib/vagrant/box_collection.rb +47 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command/base.rb +106 -0
- data/lib/vagrant/command/box.rb +33 -0
- data/lib/vagrant/command/destroy.rb +17 -0
- data/lib/vagrant/command/group_base.rb +99 -0
- data/lib/vagrant/command/halt.rb +18 -0
- data/lib/vagrant/command/helpers.rb +33 -0
- data/lib/vagrant/command/init.rb +14 -0
- data/lib/vagrant/command/named_base.rb +14 -0
- data/lib/vagrant/command/package.rb +41 -0
- data/lib/vagrant/command/provision.rb +17 -0
- data/lib/vagrant/command/reload.rb +17 -0
- data/lib/vagrant/command/resume.rb +17 -0
- data/lib/vagrant/command/ssh.rb +41 -0
- data/lib/vagrant/command/ssh_config.rb +21 -0
- data/lib/vagrant/command/status.rb +23 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +20 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +107 -189
- data/lib/vagrant/config/base.rb +67 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/nfs.rb +10 -0
- data/lib/vagrant/config/package.rb +9 -0
- data/lib/vagrant/config/ssh.rb +28 -0
- data/lib/vagrant/config/vagrant.rb +21 -0
- data/lib/vagrant/config/vm.rb +111 -0
- data/lib/vagrant/data_store.rb +68 -0
- data/lib/vagrant/downloaders/file.rb +3 -3
- data/lib/vagrant/downloaders/http.rb +5 -5
- data/lib/vagrant/environment.rb +246 -243
- data/lib/vagrant/errors.rb +306 -0
- data/lib/vagrant/hosts/base.rb +1 -1
- data/lib/vagrant/hosts/bsd.rb +3 -9
- data/lib/vagrant/hosts/linux.rb +3 -9
- data/lib/vagrant/plugin.rb +50 -0
- data/lib/vagrant/provisioners/base.rb +0 -6
- data/lib/vagrant/provisioners/chef.rb +63 -58
- data/lib/vagrant/provisioners/chef_server.rb +9 -11
- data/lib/vagrant/provisioners/chef_solo.rb +2 -2
- data/lib/vagrant/ssh.rb +34 -37
- data/lib/vagrant/systems/base.rb +0 -13
- data/lib/vagrant/systems/linux.rb +10 -33
- data/lib/vagrant/systems/solaris.rb +59 -0
- data/lib/vagrant/test_helpers.rb +109 -0
- data/lib/vagrant/ui.rb +65 -0
- data/lib/vagrant/util.rb +9 -19
- data/lib/vagrant/util/glob_loader.rb +19 -17
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +2 -0
- data/lib/vagrant/util/platform.rb +2 -0
- data/lib/vagrant/util/resource_logger.rb +5 -70
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/template_renderer.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +27 -13
- data/templates/commands/init/Vagrantfile.erb +13 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +402 -0
- data/templates/package_Vagrantfile.erb +1 -1
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +19 -103
- data/test/vagrant/action/box/destroy_test.rb +7 -19
- data/test/vagrant/action/box/download_test.rb +9 -25
- data/test/vagrant/action/box/package_test.rb +2 -2
- data/test/vagrant/action/box/unpackage_test.rb +8 -34
- data/test/vagrant/action/box/verify_test.rb +10 -19
- data/test/vagrant/action/builder_test.rb +0 -15
- data/test/vagrant/action/env/set_test.rb +1 -1
- data/test/vagrant/action/environment_test.rb +8 -26
- data/test/vagrant/action/general/package_test.rb +53 -53
- data/test/vagrant/action/vm/boot_test.rb +5 -22
- data/test/vagrant/action/vm/check_box_test.rb +35 -25
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
- data/test/vagrant/action/vm/customize_test.rb +2 -1
- data/test/vagrant/action/vm/destroy_test.rb +1 -2
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
- data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
- data/test/vagrant/action/vm/discard_state_test.rb +10 -1
- data/test/vagrant/action/vm/export_test.rb +9 -37
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
- data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
- data/test/vagrant/action/vm/halt_test.rb +11 -1
- data/test/vagrant/action/vm/import_test.rb +37 -21
- data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
- data/test/vagrant/action/vm/network_test.rb +8 -7
- data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
- data/test/vagrant/action/vm/nfs_test.rb +20 -45
- data/test/vagrant/action/vm/package_test.rb +1 -1
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
- data/test/vagrant/action/vm/provision_test.rb +10 -17
- data/test/vagrant/action/vm/resume_test.rb +1 -1
- data/test/vagrant/action/vm/share_folders_test.rb +25 -106
- data/test/vagrant/action/vm/suspend_test.rb +1 -1
- data/test/vagrant/action/warden_test.rb +105 -0
- data/test/vagrant/action_test.rb +5 -27
- data/test/vagrant/box_collection_test.rb +44 -0
- data/test/vagrant/box_test.rb +5 -105
- data/test/vagrant/cli_test.rb +35 -0
- data/test/vagrant/command/base_test.rb +23 -0
- data/test/vagrant/command/group_base_test.rb +15 -0
- data/test/vagrant/command/helpers_test.rb +88 -0
- data/test/vagrant/config/base_test.rb +52 -0
- data/test/vagrant/config/error_recorder_test.rb +18 -0
- data/test/vagrant/config/ssh_test.rb +12 -0
- data/test/vagrant/config/vagrant_test.rb +11 -0
- data/test/vagrant/config/vm_test.rb +70 -0
- data/test/vagrant/config_test.rb +113 -206
- data/test/vagrant/data_store_test.rb +68 -0
- data/test/vagrant/downloaders/base_test.rb +1 -1
- data/test/vagrant/downloaders/file_test.rb +4 -3
- data/test/vagrant/downloaders/http_test.rb +14 -4
- data/test/vagrant/environment_test.rb +290 -590
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +1 -1
- data/test/vagrant/hosts/bsd_test.rb +3 -6
- data/test/vagrant/hosts/linux_test.rb +3 -5
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +1 -1
- data/test/vagrant/provisioners/chef_server_test.rb +31 -35
- data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
- data/test/vagrant/provisioners/chef_test.rb +7 -7
- data/test/vagrant/ssh_session_test.rb +3 -10
- data/test/vagrant/ssh_test.rb +25 -33
- data/test/vagrant/systems/linux_test.rb +6 -71
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
- data/test/vagrant/util/resource_logger_test.rb +14 -81
- data/test/vagrant/util/retryable_test.rb +38 -0
- data/test/vagrant/util/template_renderer_test.rb +4 -4
- data/test/vagrant/vm_test.rb +47 -26
- data/vagrant.gemspec +14 -12
- metadata +121 -89
- data/bin/.gitignore +0 -0
- data/lib/vagrant/action/action_exception.rb +0 -16
- data/lib/vagrant/action/env/error_halt.rb +0 -16
- data/lib/vagrant/action/exception_catcher.rb +0 -14
- data/lib/vagrant/action/vm/persist.rb +0 -22
- data/lib/vagrant/active_list.rb +0 -83
- data/lib/vagrant/command.rb +0 -27
- data/lib/vagrant/commands/base.rb +0 -181
- data/lib/vagrant/commands/box.rb +0 -16
- data/lib/vagrant/commands/box/add.rb +0 -30
- data/lib/vagrant/commands/box/list.rb +0 -30
- data/lib/vagrant/commands/box/remove.rb +0 -30
- data/lib/vagrant/commands/box/repackage.rb +0 -35
- data/lib/vagrant/commands/destroy.rb +0 -37
- data/lib/vagrant/commands/halt.rb +0 -43
- data/lib/vagrant/commands/init.rb +0 -36
- data/lib/vagrant/commands/package.rb +0 -81
- data/lib/vagrant/commands/provision.rb +0 -31
- data/lib/vagrant/commands/reload.rb +0 -36
- data/lib/vagrant/commands/resume.rb +0 -35
- data/lib/vagrant/commands/ssh.rb +0 -78
- data/lib/vagrant/commands/ssh_config.rb +0 -45
- data/lib/vagrant/commands/status.rb +0 -125
- data/lib/vagrant/commands/suspend.rb +0 -36
- data/lib/vagrant/commands/up.rb +0 -44
- data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
- data/lib/vagrant/util/translator.rb +0 -35
- data/templates/strings.yml +0 -341
- data/templates/unison/crontab_entry.erb +0 -1
- data/templates/unison/script.erb +0 -71
- data/test/vagrant/action/env/error_halt_test.rb +0 -21
- data/test/vagrant/action/exception_catcher_test.rb +0 -30
- data/test/vagrant/action/vm/persist_test.rb +0 -50
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/box/repackage_test.rb +0 -52
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -71
- data/test/vagrant/commands/package_test.rb +0 -97
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -47
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -49
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class BootVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::Boot
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@vm.stubs(:ssh).returns(mock("ssh"))
|
@@ -16,14 +16,6 @@ class BootVMActionTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context "calling" do
|
19
|
-
should "do nothing if environment is erroneous" do
|
20
|
-
@env.error!(:foo)
|
21
|
-
@instance.expects(:boot).never
|
22
|
-
@app.expects(:call).never
|
23
|
-
|
24
|
-
@instance.call(@env)
|
25
|
-
end
|
26
|
-
|
27
19
|
should "run the proper methods on success" do
|
28
20
|
boot_seq = sequence("boot_seq")
|
29
21
|
@instance.expects(:boot).in_sequence(boot_seq)
|
@@ -37,18 +29,9 @@ class BootVMActionTest < Test::Unit::TestCase
|
|
37
29
|
@instance.expects(:boot).in_sequence(boot_seq)
|
38
30
|
@instance.expects(:wait_for_boot).returns(false).in_sequence(boot_seq)
|
39
31
|
@app.expects(:call).never
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
should "not continue chain if error occured" do
|
44
|
-
boot_seq = sequence("boot_seq")
|
45
|
-
@instance.expects(:boot).in_sequence(boot_seq)
|
46
|
-
@instance.expects(:wait_for_boot).returns(true).in_sequence(boot_seq).with() do
|
47
|
-
@env.error!(:interrupt)
|
48
|
-
true
|
49
|
-
end
|
50
|
-
@app.expects(:call).never
|
51
|
-
@instance.call(@env)
|
32
|
+
assert_raises(Vagrant::Errors::VMFailedToBoot) {
|
33
|
+
@instance.call(@env)
|
34
|
+
}
|
52
35
|
end
|
53
36
|
end
|
54
37
|
|
@@ -70,7 +53,7 @@ class BootVMActionTest < Test::Unit::TestCase
|
|
70
53
|
end
|
71
54
|
|
72
55
|
should "return right away if interrupted" do
|
73
|
-
@env.
|
56
|
+
@env.interrupt!
|
74
57
|
@vm.ssh.expects(:up?).times(1).returns(false)
|
75
58
|
assert @instance.wait_for_boot
|
76
59
|
end
|
@@ -3,46 +3,56 @@ require 'test_helper'
|
|
3
3
|
class CheckBoxVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::CheckBox
|
6
|
-
@app, @env = mock_action_data
|
7
|
-
@instance = @klass.new(@app, @env)
|
8
6
|
end
|
9
7
|
|
10
8
|
context "calling" do
|
11
9
|
setup do
|
12
|
-
Vagrant::Box.stubs(:find)
|
13
10
|
end
|
14
11
|
|
15
|
-
should "
|
16
|
-
|
12
|
+
should "raise error if box not specified" do
|
13
|
+
app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
|
14
|
+
config.vm.box = nil
|
15
|
+
vf
|
17
16
|
|
18
|
-
@
|
19
|
-
|
17
|
+
instance = @klass.new(app, env)
|
18
|
+
app.expects(:call).never
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
assert_raises(Vagrant::Errors::BoxNotSpecified) {
|
21
|
+
instance.call(env)
|
22
|
+
}
|
23
23
|
end
|
24
24
|
|
25
25
|
should "error if box does not exist and URL not specified" do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
|
27
|
+
config.vm.box = "yo"
|
28
|
+
config.vm.box_url = nil
|
29
|
+
vf
|
30
|
+
|
31
|
+
instance = @klass.new(app, env)
|
32
|
+
app.expects(:call).never
|
33
|
+
env.env.boxes.expects(:find).with(env["config"].vm.box).returns(nil)
|
34
|
+
|
35
|
+
assert_raises(Vagrant::Errors::BoxSpecifiedDoesntExist) {
|
36
|
+
instance.call(env)
|
37
|
+
}
|
34
38
|
end
|
35
39
|
|
36
40
|
should "attempt to download box and continue if URL specified" do
|
41
|
+
app, env = action_env(vagrant_env(vagrantfile(<<-vf)))
|
42
|
+
config.vm.box = "yo"
|
43
|
+
config.vm.box_url = "http://google.com"
|
44
|
+
vf
|
45
|
+
|
46
|
+
instance = @klass.new(app, env)
|
37
47
|
seq = sequence("seq")
|
38
|
-
|
39
|
-
Vagrant::Box.expects(:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
env.env.boxes.expects(:find).returns(nil)
|
49
|
+
Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq)
|
50
|
+
env.env.expects(:load_box!).in_sequence(seq)
|
51
|
+
app.expects(:call).with(env).once.in_sequence(seq)
|
52
|
+
|
53
|
+
assert_nothing_raised {
|
54
|
+
instance.call(env)
|
55
|
+
}
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class ClearNFSExportsActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::ClearNFSExports
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
@env.env.stubs(:host).returns(Vagrant::Hosts::Base.new(@env))
|
8
8
|
|
9
9
|
@instance = @klass.new(@app, @env)
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class CustomizeVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::Customize
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
@instance = @klass.new(@app, @env)
|
8
8
|
|
9
9
|
@vm = mock("vm")
|
@@ -14,6 +14,7 @@ class CustomizeVMActionTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
should "not run anything if no customize blocks exist" do
|
17
|
+
@env.env.config.vm.proc_stack.clear
|
17
18
|
@internal_vm.expects(:save).never
|
18
19
|
@app.expects(:call).with(@env).once
|
19
20
|
@instance.call(@env)
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class DestroyVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::Destroy
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@env["vm"] = @vm
|
@@ -18,7 +18,6 @@ class DestroyVMActionTest < Test::Unit::TestCase
|
|
18
18
|
should "destroy VM and attached images" do
|
19
19
|
@internal_vm.expects(:destroy).with(:destroy_medium => :delete).once
|
20
20
|
@env["vm"].expects(:vm=).with(nil).once
|
21
|
-
@env.env.expects(:update_dotfile).once
|
22
21
|
@app.expects(:call).with(@env).once
|
23
22
|
@instance.call(@env)
|
24
23
|
end
|
@@ -3,12 +3,13 @@ require "test_helper"
|
|
3
3
|
class DisableNetworksVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::DisableNetworks
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@env.env.stubs(:vm).returns(@vm)
|
10
10
|
|
11
11
|
@internal_vm = mock("internal")
|
12
|
+
@vm.stubs(:created?).returns(true)
|
12
13
|
@vm.stubs(:vm).returns(@internal_vm)
|
13
14
|
@internal_vm.stubs(:network_adapters).returns([])
|
14
15
|
|
@@ -27,6 +28,14 @@ class DisableNetworksVMActionTest < Test::Unit::TestCase
|
|
27
28
|
@internal_vm.network_adapters << adapter
|
28
29
|
end
|
29
30
|
|
31
|
+
should "do nothing if VM is not created" do
|
32
|
+
@vm.stubs(:created?).returns(false)
|
33
|
+
@vm.expects(:vm).never
|
34
|
+
|
35
|
+
@app.expects(:call).with(@env).once
|
36
|
+
@instance.call(@env)
|
37
|
+
end
|
38
|
+
|
30
39
|
should "remove all network adapters and continue chain" do
|
31
40
|
mock_adapter(:bridged)
|
32
41
|
mock_adapter(:host_only)
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class DiscardStateVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::DiscardState
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@env["vm"] = @vm
|
@@ -16,11 +16,20 @@ class DiscardStateVMActionTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
context "calling" do
|
18
18
|
setup do
|
19
|
+
@vm.stubs(:created?).returns(true)
|
19
20
|
@internal_vm.stubs(:saved?).returns(false)
|
20
21
|
end
|
21
22
|
|
23
|
+
should "do nothing if the VM is not created" do
|
24
|
+
@vm.stubs(:created?).returns(false)
|
25
|
+
@internal_vm.expects(:discard_state).never
|
26
|
+
@app.expects(:call).with(@env).once
|
27
|
+
@instance.call(@env)
|
28
|
+
end
|
29
|
+
|
22
30
|
should "do nothing if not saved and continue chain" do
|
23
31
|
@internal_vm.expects(:saved?).returns(false)
|
32
|
+
@internal_vm.expects(:discard_state).never
|
24
33
|
@app.expects(:call).with(@env).once
|
25
34
|
@instance.call(@env)
|
26
35
|
end
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class ExportVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::Export
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@env["vm"] = @vm
|
@@ -24,7 +24,7 @@ class ExportVMActionTest < Test::Unit::TestCase
|
|
24
24
|
@instance.expects(:setup_temp_dir).in_sequence(seq)
|
25
25
|
@instance.expects(:export).in_sequence(seq)
|
26
26
|
@app.expects(:call).with(@env).in_sequence(seq)
|
27
|
-
@instance.expects(:
|
27
|
+
@instance.expects(:recover).in_sequence(seq).with(@env)
|
28
28
|
|
29
29
|
@instance.call(@env)
|
30
30
|
end
|
@@ -34,36 +34,11 @@ class ExportVMActionTest < Test::Unit::TestCase
|
|
34
34
|
@instance.expects(:setup_temp_dir).never
|
35
35
|
@instance.expects(:export).never
|
36
36
|
@app.expects(:call).with(@env).never
|
37
|
-
@instance.expects(:
|
37
|
+
@instance.expects(:recover).never
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
should "halt the chain if env error" do
|
45
|
-
@internal_vm.stubs(:powered_off?).returns(true)
|
46
|
-
@instance.expects(:setup_temp_dir).never
|
47
|
-
@instance.expects(:export).never
|
48
|
-
@app.expects(:call).with(@env).never
|
49
|
-
@instance.expects(:cleanup).never
|
50
|
-
|
51
|
-
@env.error!(:interrupt)
|
52
|
-
@instance.call(@env)
|
53
|
-
end
|
54
|
-
|
55
|
-
should "halt the chain if env error when call is reached" do
|
56
|
-
@internal_vm.stubs(:powered_off?).returns(true)
|
57
|
-
@instance.expects(:setup_temp_dir).once
|
58
|
-
@instance.expects(:export).once.with() do
|
59
|
-
@env.error!(:interrupt)
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
@app.expects(:call).with(@env).never
|
64
|
-
@instance.expects(:cleanup).once
|
65
|
-
|
66
|
-
@instance.call(@env)
|
39
|
+
assert_raises(Vagrant::Errors::VMPowerOffToPackage) {
|
40
|
+
@instance.call(@env)
|
41
|
+
}
|
67
42
|
end
|
68
43
|
end
|
69
44
|
|
@@ -76,13 +51,13 @@ class ExportVMActionTest < Test::Unit::TestCase
|
|
76
51
|
|
77
52
|
should "delete the temporary file if it exists" do
|
78
53
|
File.expects(:unlink).with(@temp_dir).once
|
79
|
-
@instance.
|
54
|
+
@instance.recover(nil)
|
80
55
|
end
|
81
56
|
|
82
57
|
should "not delete anything if it doesn't exist" do
|
83
58
|
File.stubs(:exist?).returns(false)
|
84
59
|
File.expects(:unlink).never
|
85
|
-
@instance.
|
60
|
+
@instance.recover(nil)
|
86
61
|
end
|
87
62
|
end
|
88
63
|
|
@@ -91,10 +66,7 @@ class ExportVMActionTest < Test::Unit::TestCase
|
|
91
66
|
@time_now = Time.now.to_i.to_s
|
92
67
|
Time.stubs(:now).returns(@time_now)
|
93
68
|
|
94
|
-
@
|
95
|
-
@env.env.stubs(:tmp_path).returns(@tmp_path)
|
96
|
-
|
97
|
-
@temp_dir = File.join(@env.env.tmp_path, @time_now)
|
69
|
+
@temp_dir = @env.env.tmp_path.join(@time_now)
|
98
70
|
FileUtils.stubs(:mkpath)
|
99
71
|
end
|
100
72
|
|
@@ -3,11 +3,11 @@ require "test_helper"
|
|
3
3
|
class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Class.new do
|
6
|
+
include Vagrant::Action::VM::ForwardPortsHelpers
|
6
7
|
def initialize(env); @env = env; end
|
7
8
|
end
|
8
9
|
|
9
|
-
@
|
10
|
-
@app, @env = mock_action_data
|
10
|
+
@app, @env = action_env
|
11
11
|
|
12
12
|
@vm = mock("vm")
|
13
13
|
@vm.stubs(:name).returns("foo")
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class ForwardPortsVMActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::VM::ForwardPorts
|
6
|
-
@app, @env =
|
6
|
+
@app, @env = action_env
|
7
7
|
|
8
8
|
@vm = mock("vm")
|
9
9
|
@vm.stubs(:name).returns("foo")
|
@@ -26,16 +26,19 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
|
26
26
|
should "error if has a port below threshold" do
|
27
27
|
@env.env.config.vm.forwarded_ports.clear
|
28
28
|
@env.env.config.vm.forward_port("foo", 22, 222)
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
|
30
|
+
assert_raises(Vagrant::Errors::ForwardPortBelowThreshold) {
|
31
|
+
@klass.new(@app, @env)
|
32
|
+
}
|
32
33
|
end
|
33
34
|
|
34
35
|
should "not error if ports are fine" do
|
35
36
|
@env.env.config.vm.forwarded_ports.clear
|
36
37
|
@env.env.config.vm.forward_port("foo", 22, 2222)
|
37
|
-
|
38
|
-
|
38
|
+
|
39
|
+
assert_nothing_raised {
|
40
|
+
@klass.new(@app, @env)
|
41
|
+
}
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -51,15 +54,13 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
|
51
54
|
|
52
55
|
should "not raise any errors if no forwarded ports collide" do
|
53
56
|
@used_ports << "80"
|
54
|
-
@klass.new(@app, @env)
|
55
|
-
assert !@env.error?
|
57
|
+
assert_nothing_raised { @klass.new(@app, @env) }
|
56
58
|
end
|
57
59
|
|
58
60
|
should "handle collision if it happens" do
|
59
61
|
@used_ports << "2222"
|
60
62
|
@klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once
|
61
|
-
@klass.new(@app, @env)
|
62
|
-
assert !@env.error?
|
63
|
+
assert_nothing_raised { @klass.new(@app, @env) }
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
@@ -84,9 +85,10 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
|
84
85
|
|
85
86
|
should "error if auto forwarding is disabled" do
|
86
87
|
@options[:auto] = false
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
|
89
|
+
assert_raises(Vagrant::Errors::ForwardPortCollision) {
|
90
|
+
@instance.handle_collision(@name, @options, @used_ports)
|
91
|
+
}
|
90
92
|
end
|
91
93
|
|
92
94
|
should "set the host port to the first available port" do
|
@@ -111,9 +113,10 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
|
111
113
|
|
112
114
|
should "raise an exception if there are no auto ports available" do
|
113
115
|
@env.env.config.vm.auto_port_range = (1..3)
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
|
117
|
+
assert_raises(Vagrant::Errors::ForwardPortAutolistEmpty) {
|
118
|
+
@instance.handle_collision(@name, @options, @used_ports)
|
119
|
+
}
|
117
120
|
end
|
118
121
|
end
|
119
122
|
|