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,28 +3,16 @@ require "test_helper"
|
|
3
3
|
class DestroyBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Box::Destroy
|
6
|
-
@app, @env =
|
7
|
-
|
8
|
-
@vm = mock("vm")
|
9
|
-
@env["vm"] = @vm
|
10
|
-
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
11
|
-
|
12
|
-
@internal_vm = mock("internal")
|
13
|
-
@vm.stubs(:vm).returns(@internal_vm)
|
6
|
+
@app, @env = action_env
|
7
|
+
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
14
8
|
|
15
9
|
@instance = @klass.new(@app, @env)
|
16
10
|
end
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
should "delete the box directory" do
|
24
|
-
seq = sequence("seq")
|
25
|
-
FileUtils.expects(:rm_rf).with(@env["box"].directory).in_sequence(seq)
|
26
|
-
@app.expects(:call).with(@env).once.in_sequence(seq)
|
27
|
-
@instance.call(@env)
|
28
|
-
end
|
12
|
+
should "delete the box directory" do
|
13
|
+
seq = sequence("seq")
|
14
|
+
FileUtils.expects(:rm_rf).with(@env["box"].directory).in_sequence(seq)
|
15
|
+
@app.expects(:call).with(@env).once.in_sequence(seq)
|
16
|
+
@instance.call(@env)
|
29
17
|
end
|
30
18
|
end
|
@@ -3,15 +3,9 @@ require "test_helper"
|
|
3
3
|
class DownloadBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Box::Download
|
6
|
-
@app, @env =
|
7
|
-
|
8
|
-
@vm = mock("vm")
|
9
|
-
@env["vm"] = @vm
|
10
|
-
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
6
|
+
@app, @env = action_env
|
7
|
+
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
11
8
|
@env["box"].uri = "http://google.com"
|
12
|
-
|
13
|
-
@internal_vm = mock("internal")
|
14
|
-
@vm.stubs(:vm).returns(@internal_vm)
|
15
9
|
end
|
16
10
|
|
17
11
|
context "initializing" do
|
@@ -32,17 +26,7 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
32
26
|
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(true)
|
33
27
|
@instance.expects(:download).in_sequence(seq)
|
34
28
|
@app.expects(:call).with(@env).in_sequence(seq)
|
35
|
-
@instance.expects(:
|
36
|
-
@instance.call(@env)
|
37
|
-
end
|
38
|
-
|
39
|
-
should "halt the chain if downloader instantiation fails" do
|
40
|
-
seq = sequence("seq")
|
41
|
-
@env.error!(:foo)
|
42
|
-
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(false)
|
43
|
-
@instance.expects(:download).never
|
44
|
-
@app.expects(:call).with(@env).never
|
45
|
-
@instance.expects(:cleanup).never
|
29
|
+
@instance.expects(:recover).with(@env).in_sequence(seq)
|
46
30
|
@instance.call(@env)
|
47
31
|
end
|
48
32
|
end
|
@@ -57,9 +41,9 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
57
41
|
|
58
42
|
should "error environment if URI is invalid for any downloaders" do
|
59
43
|
@env["box"].uri = "foobar"
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
assert_raises(Vagrant::Errors::BoxDownloadUnknownType) {
|
45
|
+
@instance.instantiate_downloader
|
46
|
+
}
|
63
47
|
end
|
64
48
|
end
|
65
49
|
|
@@ -91,7 +75,7 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
91
75
|
context "tempfile" do
|
92
76
|
should "create a tempfile in the vagrant tmp directory" do
|
93
77
|
File.expects(:open).with { |name, bitmask|
|
94
|
-
name =~ /#{Vagrant::Action::Box::Download::BASENAME}/ && name =~ /#{@env.env.tmp_path}/
|
78
|
+
name.to_s =~ /#{Vagrant::Action::Box::Download::BASENAME}/ && name.to_s =~ /#{@env.env.tmp_path}/
|
95
79
|
}.once
|
96
80
|
@instance.with_tempfile
|
97
81
|
end
|
@@ -115,13 +99,13 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
115
99
|
|
116
100
|
should "delete the temporary file if it exists" do
|
117
101
|
File.expects(:unlink).with(@temp_path).once
|
118
|
-
@instance.
|
102
|
+
@instance.recover(@env)
|
119
103
|
end
|
120
104
|
|
121
105
|
should "not delete anything if it doesn't exist" do
|
122
106
|
File.stubs(:exist?).returns(false)
|
123
107
|
File.expects(:unlink).never
|
124
|
-
@instance.
|
108
|
+
@instance.recover(@env)
|
125
109
|
end
|
126
110
|
end
|
127
111
|
|
@@ -3,8 +3,8 @@ require "test_helper"
|
|
3
3
|
class PackageBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Box::Package
|
6
|
-
@app, @env =
|
7
|
-
@env["box"] = Vagrant::Box.new(
|
6
|
+
@app, @env = action_env
|
7
|
+
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
8
8
|
|
9
9
|
@instance = @klass.new(@app, @env)
|
10
10
|
end
|
@@ -3,14 +3,8 @@ require "test_helper"
|
|
3
3
|
class UnpackageBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Box::Unpackage
|
6
|
-
@app, @env =
|
7
|
-
|
8
|
-
@vm = mock("vm")
|
9
|
-
@env["vm"] = @vm
|
10
|
-
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
11
|
-
|
12
|
-
@internal_vm = mock("internal")
|
13
|
-
@vm.stubs(:vm).returns(@internal_vm)
|
6
|
+
@app, @env = action_env
|
7
|
+
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
14
8
|
|
15
9
|
@instance = @klass.new(@app, @env)
|
16
10
|
end
|
@@ -21,26 +15,6 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
21
15
|
@instance.expects(:setup_box_directory).in_sequence(seq).returns(true)
|
22
16
|
@instance.expects(:decompress).in_sequence(seq)
|
23
17
|
@app.expects(:call).with(@env)
|
24
|
-
@instance.expects(:cleanup).never
|
25
|
-
@instance.call(@env)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "halt the chain if setting up the box directory fails" do
|
29
|
-
@instance.expects(:setup_box_directory).returns(false)
|
30
|
-
@instance.expects(:decompress).never
|
31
|
-
@app.expects(:call).never
|
32
|
-
@instance.expects(:cleanup).never
|
33
|
-
@instance.call(@env)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "cleanup if there was an error" do
|
37
|
-
@env.error!(:foo)
|
38
|
-
|
39
|
-
seq = sequence("sequence")
|
40
|
-
@instance.expects(:setup_box_directory).in_sequence(seq).returns(true)
|
41
|
-
@instance.expects(:decompress).in_sequence(seq)
|
42
|
-
@app.expects(:call).with(@env)
|
43
|
-
@instance.expects(:cleanup).once
|
44
18
|
@instance.call(@env)
|
45
19
|
end
|
46
20
|
end
|
@@ -54,13 +28,13 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
54
28
|
|
55
29
|
should "do nothing if not a directory" do
|
56
30
|
FileUtils.expects(:rm_rf).never
|
57
|
-
@instance.
|
31
|
+
@instance.recover(nil)
|
58
32
|
end
|
59
33
|
|
60
34
|
should "remove the directory if exists" do
|
61
35
|
File.expects(:directory?).with(@instance.box_directory).once.returns(true)
|
62
36
|
FileUtils.expects(:rm_rf).with(@instance.box_directory).once
|
63
|
-
@instance.
|
37
|
+
@instance.recover(nil)
|
64
38
|
end
|
65
39
|
end
|
66
40
|
|
@@ -72,9 +46,9 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
72
46
|
|
73
47
|
should "error the environment if the box already exists" do
|
74
48
|
File.expects(:directory?).returns(true)
|
75
|
-
|
76
|
-
|
77
|
-
|
49
|
+
assert_raises(Vagrant::Errors::BoxAlreadyExists) {
|
50
|
+
@instance.setup_box_directory
|
51
|
+
}
|
78
52
|
end
|
79
53
|
|
80
54
|
should "create the directory" do
|
@@ -96,7 +70,7 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
96
70
|
end
|
97
71
|
|
98
72
|
should "open the tar file within the new directory, and extract it all" do
|
99
|
-
Archive::Tar::Minitar.expects(:unpack).with(@env["download.temp_path"], @env["box"].directory).once
|
73
|
+
Archive::Tar::Minitar.expects(:unpack).with(@env["download.temp_path"], @env["box"].directory.to_s).once
|
100
74
|
@instance.decompress
|
101
75
|
end
|
102
76
|
end
|
@@ -3,37 +3,28 @@ require "test_helper"
|
|
3
3
|
class VerifyBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Box::Verify
|
6
|
-
@app, @env =
|
7
|
-
|
8
|
-
@vm = mock("vm")
|
9
|
-
@env["vm"] = @vm
|
10
|
-
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
11
|
-
|
12
|
-
@internal_vm = mock("internal")
|
13
|
-
@vm.stubs(:vm).returns(@internal_vm)
|
6
|
+
@app, @env = action_env
|
7
|
+
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
14
8
|
|
15
9
|
@instance = @klass.new(@app, @env)
|
16
10
|
end
|
17
11
|
|
18
12
|
context "calling" do
|
19
|
-
setup do
|
20
|
-
@env.logger.stubs(:info)
|
21
|
-
end
|
22
|
-
|
23
13
|
should "continue fine if verification succeeds" do
|
24
14
|
seq = sequence("seq")
|
25
|
-
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
|
15
|
+
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file.to_s).in_sequence(seq)
|
26
16
|
@app.expects(:call).with(@env).once.in_sequence(seq)
|
27
|
-
|
28
|
-
|
17
|
+
assert_nothing_raised {
|
18
|
+
@instance.call(@env)
|
19
|
+
}
|
29
20
|
end
|
30
21
|
|
31
22
|
should "halt chain if verification fails" do
|
32
|
-
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).raises(Exception)
|
23
|
+
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file.to_s).raises(Exception)
|
33
24
|
@app.expects(:call).with(@env).never
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
assert_raises(Vagrant::Errors::BoxVerificationFailed) {
|
26
|
+
@instance.call(@env)
|
27
|
+
}
|
37
28
|
end
|
38
29
|
end
|
39
30
|
end
|
@@ -155,21 +155,6 @@ class ActionBuilderTest < Test::Unit::TestCase
|
|
155
155
|
end
|
156
156
|
|
157
157
|
context "converting to an app" do
|
158
|
-
teardown do
|
159
|
-
Vagrant::Action.actions.clear
|
160
|
-
end
|
161
|
-
|
162
|
-
should "preprend error halt to the chain" do
|
163
|
-
result = mock("result")
|
164
|
-
env = {:a => :b}
|
165
|
-
middleware = mock("middleware")
|
166
|
-
middleware.stubs(:is_a?).with(Class).returns(true)
|
167
|
-
middleware.expects(:new).with(anything, env).returns(result)
|
168
|
-
@instance.use middleware
|
169
|
-
result = @instance.to_app(env)
|
170
|
-
assert result.kind_of?(Vagrant::Action::Env::ErrorHalt)
|
171
|
-
end
|
172
|
-
|
173
158
|
should "make non-classes lambdas" do
|
174
159
|
env = Vagrant::Action::Environment.new(nil)
|
175
160
|
env.expects(:foo).once
|
@@ -3,7 +3,11 @@ require "test_helper"
|
|
3
3
|
class ActionEnvironmentTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::Environment
|
6
|
-
@instance = @klass.new(
|
6
|
+
@instance = @klass.new(vagrant_env)
|
7
|
+
end
|
8
|
+
|
9
|
+
should "be a hash with indifferent access" do
|
10
|
+
assert @instance.is_a?(Vagrant::Util::HashWithIndifferentAccess)
|
7
11
|
end
|
8
12
|
|
9
13
|
should "default values to those on the env" do
|
@@ -11,35 +15,13 @@ class ActionEnvironmentTest < Test::Unit::TestCase
|
|
11
15
|
assert_equal "value", @instance["key"]
|
12
16
|
end
|
13
17
|
|
14
|
-
should "setup the
|
15
|
-
assert_equal @instance.env.
|
16
|
-
end
|
17
|
-
|
18
|
-
should "not be erroneous initially" do
|
19
|
-
assert !@instance.error?
|
20
|
-
end
|
21
|
-
|
22
|
-
should "mark as erroneous" do
|
23
|
-
@instance.error!(:key)
|
24
|
-
assert_equal [:key, {}], @instance.error
|
25
|
-
end
|
26
|
-
|
27
|
-
should "properly report erroneous" do
|
28
|
-
@instance.error!(:key)
|
29
|
-
assert @instance.error?
|
18
|
+
should "setup the UI" do
|
19
|
+
assert_equal @instance.env.ui, @instance.ui
|
30
20
|
end
|
31
21
|
|
32
22
|
should "report interrupted if interrupt error" do
|
33
23
|
assert !@instance.interrupted?
|
34
|
-
@instance.
|
24
|
+
@instance.interrupt!
|
35
25
|
assert @instance.interrupted?
|
36
26
|
end
|
37
|
-
|
38
|
-
should "have indifferent access" do
|
39
|
-
@instance[:foo] = :bar
|
40
|
-
@instance["bar"] = :baz
|
41
|
-
|
42
|
-
assert_equal :bar, @instance["foo"]
|
43
|
-
assert_equal :baz, @instance[:bar]
|
44
|
-
end
|
45
27
|
end
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class PackageGeneralActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Action::General::Package
|
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 PackageGeneralActionTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
should "initialize fine" do
|
20
20
|
@klass.new(@app, @env)
|
21
|
-
assert !@env.error?
|
22
21
|
end
|
23
22
|
|
24
23
|
should "set the output path to configured by default" do
|
@@ -37,7 +36,7 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
|
37
36
|
assert_equal [], @env["package.include"]
|
38
37
|
end
|
39
38
|
|
40
|
-
should "not set the
|
39
|
+
should "not set the include path if it is already set" do
|
41
40
|
@env["package.include"] = "foo"
|
42
41
|
@klass.new(@app, @env)
|
43
42
|
assert_equal "foo", @env["package.include"]
|
@@ -56,58 +55,34 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
|
56
55
|
context "calling" do
|
57
56
|
should "call the proper methods then continue chain" do
|
58
57
|
seq = sequence("seq")
|
59
|
-
@instance.expects(:
|
58
|
+
@instance.expects(:verify_files_to_copy).in_sequence(seq).returns(true)
|
60
59
|
@instance.expects(:compress).in_sequence(seq)
|
61
60
|
@app.expects(:call).with(@env).in_sequence(seq)
|
62
|
-
@instance.expects(:cleanup).never
|
63
|
-
|
64
|
-
@instance.call(@env)
|
65
|
-
end
|
66
|
-
|
67
|
-
should "halt the chain if verify failed" do
|
68
|
-
@instance.expects(:verify_included_files).returns(false)
|
69
|
-
@instance.expects(:compress).never
|
70
|
-
@app.expects(:call).never
|
71
|
-
|
72
61
|
@instance.call(@env)
|
73
62
|
end
|
74
63
|
|
75
64
|
should "halt the chain if the output file already exists" do
|
76
65
|
File.expects(:exist?).returns(true)
|
77
66
|
@app.expects(:call).never
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
assert_equal :package_output_exists, @env.error.first
|
67
|
+
assert_raises(Vagrant::Errors::PackageOutputExists) {
|
68
|
+
@instance.call(@env)
|
69
|
+
}
|
82
70
|
end
|
83
71
|
|
84
72
|
should "halt the chain if directory isn't set" do
|
85
73
|
@env["package.directory"] = nil
|
86
74
|
@app.expects(:call).never
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
assert_equal :package_requires_directory, @env.error.first
|
75
|
+
assert_raises(Vagrant::Errors::PackageRequiresDirectory) {
|
76
|
+
@instance.call(@env)
|
77
|
+
}
|
91
78
|
end
|
92
79
|
|
93
80
|
should "halt the chain if directory doesn't exist" do
|
94
81
|
File.expects(:directory?).with(@env["package.directory"]).returns(false)
|
95
82
|
@app.expects(:call).never
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
assert_equal :package_requires_directory, @env.error.first
|
100
|
-
end
|
101
|
-
|
102
|
-
should "run cleanup if environment errors" do
|
103
|
-
seq = sequence("seq")
|
104
|
-
@instance.expects(:verify_included_files).in_sequence(seq).returns(true)
|
105
|
-
@instance.expects(:compress).in_sequence(seq)
|
106
|
-
@app.expects(:call).with(@env).in_sequence(seq)
|
107
|
-
@instance.expects(:cleanup).in_sequence(seq)
|
108
|
-
|
109
|
-
@env.error!(:foo)
|
110
|
-
@instance.call(@env)
|
83
|
+
assert_raises(Vagrant::Errors::PackageRequiresDirectory) {
|
84
|
+
@instance.call(@env)
|
85
|
+
}
|
111
86
|
end
|
112
87
|
end
|
113
88
|
|
@@ -123,18 +98,45 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
|
123
98
|
File.expects(:exist?).with(@instance.tar_path).returns(false)
|
124
99
|
File.expects(:delete).never
|
125
100
|
|
126
|
-
@instance.
|
101
|
+
@instance.recover(@env)
|
127
102
|
end
|
128
103
|
|
129
104
|
should "delete the packaged box if it exists" do
|
130
105
|
File.expects(:exist?).returns(true)
|
131
106
|
File.expects(:delete).with(@instance.tar_path).once
|
132
107
|
|
133
|
-
@instance.
|
108
|
+
@instance.recover(@env)
|
134
109
|
end
|
135
110
|
end
|
136
111
|
|
137
|
-
context "
|
112
|
+
context "files to copy" do
|
113
|
+
setup do
|
114
|
+
@env["package.include"] = []
|
115
|
+
@package_dir = Pathname.new(@env["package.directory"]).join("include")
|
116
|
+
end
|
117
|
+
|
118
|
+
should "have included files whole path if relative" do
|
119
|
+
path = "lib/foo"
|
120
|
+
@env["package.include"] = [path]
|
121
|
+
result = @instance.files_to_copy
|
122
|
+
assert_equal @package_dir.join(path), result[path]
|
123
|
+
end
|
124
|
+
|
125
|
+
should "have the filename if an absolute path" do
|
126
|
+
path = "/foo/bar"
|
127
|
+
@env["package.include"] = [path]
|
128
|
+
result = @instance.files_to_copy
|
129
|
+
assert_equal @package_dir.join("bar"), result[path]
|
130
|
+
end
|
131
|
+
|
132
|
+
should "include the Vagrantfile if specified" do
|
133
|
+
@env["package.vagrantfile"] = "foo"
|
134
|
+
result = @instance.files_to_copy
|
135
|
+
assert_equal @package_dir.join("_Vagrantfile"), result["foo"]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "verifying files to copy" do
|
138
140
|
setup do
|
139
141
|
@env["package.include"] = ["foo"]
|
140
142
|
File.stubs(:exist?).returns(true)
|
@@ -142,14 +144,15 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
|
142
144
|
|
143
145
|
should "error if included file is not found" do
|
144
146
|
File.expects(:exist?).with("foo").returns(false)
|
145
|
-
|
146
|
-
|
147
|
-
|
147
|
+
assert_raises(Vagrant::Errors::PackageIncludeMissing) {
|
148
|
+
@instance.verify_files_to_copy
|
149
|
+
}
|
148
150
|
end
|
149
151
|
|
150
152
|
should "return true if all exist" do
|
151
|
-
|
152
|
-
|
153
|
+
assert_nothing_raised {
|
154
|
+
assert @instance.verify_files_to_copy
|
155
|
+
}
|
153
156
|
end
|
154
157
|
end
|
155
158
|
|
@@ -166,14 +169,11 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
|
166
169
|
end
|
167
170
|
|
168
171
|
should "create the include directory and copy files to it" do
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
file = mock("f#{i}")
|
175
|
-
@env["package.include"] << file
|
176
|
-
FileUtils.expects(:cp).with(file, include_dir).in_sequence(copy_seq)
|
172
|
+
@env["package.include"] = ["/foo/bar", "lib/foo"]
|
173
|
+
seq = sequence("seq")
|
174
|
+
@instance.files_to_copy.each do |from, to|
|
175
|
+
FileUtils.expects(:mkdir_p).with(to.parent).in_sequence(seq)
|
176
|
+
FileUtils.expects(:cp).with(from, to).in_sequence(seq)
|
177
177
|
end
|
178
178
|
|
179
179
|
@instance.copy_include_files
|