vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
@@ -1,45 +1,56 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("../../base", __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
clean_paths
|
3
|
+
describe Vagrant::BoxCollection do
|
4
|
+
include_context "unit"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
should "load all the boxes from the box path" do
|
11
|
-
vagrant_box("foo")
|
12
|
-
vagrant_box("bar")
|
13
|
-
|
14
|
-
result = @klass.new(vagrant_env)
|
15
|
-
names = result.collect { |b| b.name }.sort
|
16
|
-
assert result.length >= 2
|
17
|
-
assert names.include?("foo")
|
18
|
-
assert names.include?("bar")
|
19
|
-
end
|
20
|
-
|
21
|
-
should "reload the box list" do
|
22
|
-
instance = @klass.new(vagrant_env)
|
23
|
-
amount = instance.length
|
6
|
+
let(:environment) { isolated_environment }
|
7
|
+
let(:action_runner) { double("action runner") }
|
8
|
+
let(:instance) { described_class.new(environment.boxes_dir, action_runner) }
|
24
9
|
|
25
|
-
|
10
|
+
it "should list all available boxes" do
|
11
|
+
# No boxes yet.
|
12
|
+
instance.length.should == 0
|
26
13
|
|
14
|
+
# Add some boxes to the environment and try again
|
15
|
+
environment.box("foo")
|
16
|
+
environment.box("bar")
|
27
17
|
instance.reload!
|
28
|
-
|
18
|
+
instance.length.should == 2
|
29
19
|
end
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
describe "finding" do
|
22
|
+
it "should return nil if it can't find the box" do
|
23
|
+
instance.find("foo").should be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return a box instance for any boxes it does find" do
|
27
|
+
environment.box("foo")
|
28
|
+
result = instance.find("foo")
|
29
|
+
result.should be_kind_of(Vagrant::Box)
|
30
|
+
result.name.should == "foo"
|
31
|
+
end
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal "foo", result.name
|
34
|
+
it "should throw an error if the box already exists when adding" do
|
35
|
+
environment.box("foo")
|
36
|
+
expect { instance.add("foo", "bar") }.to raise_error(Vagrant::Errors::BoxAlreadyExists)
|
39
37
|
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
it "should add the box" do
|
40
|
+
name = "foo"
|
41
|
+
url = "bar"
|
42
|
+
|
43
|
+
# Test the invocation of the action runner with the proper name
|
44
|
+
# and parameters. We leave the testing of the actual stack to
|
45
|
+
# acceptance tests, and individual pieces to unit tests of each
|
46
|
+
# step.
|
47
|
+
options = {
|
48
|
+
:box_name => name,
|
49
|
+
:box_url => url,
|
50
|
+
:box_directory => instance.directory.join(name)
|
51
|
+
}
|
52
|
+
action_runner.should_receive(:run).with(:box_add, options)
|
53
|
+
|
54
|
+
instance.add(name, url)
|
44
55
|
end
|
45
56
|
end
|
@@ -1,74 +1,34 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("../../base", __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe Vagrant::Box do
|
4
|
+
let(:name) { "foo" }
|
5
|
+
let(:directory) { "bar" }
|
6
|
+
let(:action_runner) { double("action_runner") }
|
7
|
+
let(:instance) { described_class.new(name, directory, action_runner) }
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
@name = "foo"
|
12
|
-
@uri = "bar"
|
13
|
-
end
|
14
|
-
|
15
|
-
should "create a new instance, set the variables, and add it" do
|
16
|
-
box = mock("box")
|
17
|
-
box.expects(:uri=).with(@uri)
|
18
|
-
box.expects(:add).once
|
19
|
-
Vagrant::Box.expects(:new).with(@env, @name).returns(box)
|
20
|
-
Vagrant::Box.add(@env, @name, @uri)
|
21
|
-
end
|
22
|
-
end
|
9
|
+
it "provides the name" do
|
10
|
+
instance.name.should == name
|
23
11
|
end
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
assert_raises(Vagrant::Errors::BoxAlreadyExists) {
|
34
|
-
@box.add
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
should "execute the Add action when add is called" do
|
39
|
-
@box.env.actions.expects(:run).with(:box_add, { "box" => @box, "validate" => false })
|
40
|
-
@box.add
|
41
|
-
end
|
13
|
+
it "can destroy itself" do
|
14
|
+
# Simply test the messages to the action runner
|
15
|
+
options = {
|
16
|
+
:box_name => name,
|
17
|
+
:box_directory => directory
|
18
|
+
}
|
19
|
+
action_runner.should_receive(:run).with(:box_remove, options)
|
42
20
|
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal @box.env.boxes_path.join(@box.name), @box.directory
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "destroying" do
|
50
|
-
should "execute the destroy action" do
|
51
|
-
@box.env.actions.expects(:run).with(:box_remove, { "box" => @box, "validate" => false })
|
52
|
-
@box.destroy
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "repackaging" do
|
57
|
-
should "execute the repackage action" do
|
58
|
-
@box.env.actions.expects(:run).with(:box_repackage, { "box" => @box, "validate" => false })
|
59
|
-
@box.repackage
|
60
|
-
end
|
21
|
+
instance.destroy
|
22
|
+
end
|
61
23
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
24
|
+
it "can repackage itself" do
|
25
|
+
# Simply test the messages to the action runner
|
26
|
+
options = {
|
27
|
+
:box_name => name,
|
28
|
+
:box_directory => directory
|
29
|
+
}
|
30
|
+
action_runner.should_receive(:run).with(:box_repackage, options)
|
67
31
|
|
68
|
-
|
69
|
-
should "be the directory joined with the config ovf file" do
|
70
|
-
assert_equal @box.directory.join(@box.env.config.vm.box_ovf), @box.ovf_file
|
71
|
-
end
|
72
|
-
end
|
32
|
+
instance.repackage
|
73
33
|
end
|
74
34
|
end
|
@@ -1,23 +1,150 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
|
+
require 'optparse'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
describe Vagrant::Command::Base do
|
5
|
+
describe "parsing options" do
|
6
|
+
let(:klass) do
|
7
|
+
Class.new(described_class) do
|
8
|
+
# Make the method public since it is normally protected
|
9
|
+
public :parse_options
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns the remaining arguments" do
|
14
|
+
options = {}
|
15
|
+
opts = OptionParser.new do |opts|
|
16
|
+
opts.on("-f") do |f|
|
17
|
+
options[:f] = f
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
result = klass.new(["-f", "foo"], nil).parse_options(opts)
|
22
|
+
|
23
|
+
# Check the results
|
24
|
+
options[:f].should be
|
25
|
+
result.should == ["foo"]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "creates an option parser if none is given" do
|
29
|
+
result = klass.new(["foo"], nil).parse_options(nil)
|
30
|
+
result.should == ["foo"]
|
31
|
+
end
|
32
|
+
|
33
|
+
["-h", "--help"].each do |help_string|
|
34
|
+
it "returns nil and prints the help if '#{help_string}' is given" do
|
35
|
+
instance = klass.new([help_string], nil)
|
36
|
+
instance.should_receive(:puts)
|
37
|
+
instance.parse_options(OptionParser.new).should be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises an error if invalid options are given" do
|
42
|
+
instance = klass.new(["-f"], nil)
|
43
|
+
expect { instance.parse_options(OptionParser.new) }.
|
44
|
+
to raise_error(Vagrant::Errors::CLIInvalidOptions)
|
45
|
+
end
|
7
46
|
end
|
8
47
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
48
|
+
describe "target VMs" do
|
49
|
+
let(:klass) do
|
50
|
+
Class.new(described_class) do
|
51
|
+
# Make the method public since it is normally protected
|
52
|
+
public :with_target_vms
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:environment) do
|
57
|
+
env = double("environment")
|
58
|
+
env.stub(:root_path => "foo")
|
59
|
+
env
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:instance) { klass.new([], environment) }
|
63
|
+
|
64
|
+
it "should raise an exception if a root_path is not available" do
|
65
|
+
environment.stub(:root_path => nil)
|
66
|
+
|
67
|
+
expect { instance.with_target_vms }.
|
68
|
+
to raise_error(Vagrant::Errors::NoEnvironmentError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should raise an exception if a name is given in a non-multivm environment" do
|
72
|
+
environment.stub(:multivm?).and_return(false)
|
73
|
+
|
74
|
+
expect { instance.with_target_vms("foo") }.
|
75
|
+
to raise_error(Vagrant::Errors::MultiVMEnvironmentRequired)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should yield every VM in order is no name is given" do
|
79
|
+
foo_vm = double("foo")
|
80
|
+
foo_vm.stub(:name).and_return("foo")
|
81
|
+
|
82
|
+
bar_vm = double("bar")
|
83
|
+
bar_vm.stub(:name).and_return("bar")
|
84
|
+
|
85
|
+
environment.stub(:multivm? => true,
|
86
|
+
:vms => { "foo" => foo_vm, "bar" => bar_vm },
|
87
|
+
:vms_ordered => [foo_vm, bar_vm])
|
88
|
+
|
89
|
+
vms = []
|
90
|
+
instance.with_target_vms do |vm|
|
91
|
+
vms << vm
|
92
|
+
end
|
93
|
+
|
94
|
+
vms.should == [foo_vm, bar_vm]
|
95
|
+
end
|
96
|
+
|
97
|
+
it "raises an exception if the named VM doesn't exist" do
|
98
|
+
environment.stub(:multivm? => true, :vms => {})
|
99
|
+
|
100
|
+
expect { instance.with_target_vms("foo") }.
|
101
|
+
to raise_error(Vagrant::Errors::VMNotFoundError)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "yields the given VM if a name is given" do
|
105
|
+
foo_vm = double("foo")
|
106
|
+
foo_vm.stub(:name).and_return(:foo)
|
107
|
+
|
108
|
+
environment.stub(:multivm? => true,
|
109
|
+
:vms => { :foo => foo_vm, :bar => nil })
|
110
|
+
|
111
|
+
vms = []
|
112
|
+
instance.with_target_vms("foo") { |vm| vms << vm }
|
113
|
+
vms.should == [foo_vm]
|
13
114
|
end
|
14
115
|
end
|
15
116
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
117
|
+
describe "splitting the main and subcommand args" do
|
118
|
+
let(:instance) do
|
119
|
+
Class.new(described_class) do
|
120
|
+
# Make the method public since it is normally protected
|
121
|
+
public :split_main_and_subcommand
|
122
|
+
end.new(nil, nil)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should work when given all 3 parts" do
|
126
|
+
result = instance.split_main_and_subcommand(["-v", "status", "-h", "-v"])
|
127
|
+
result.should == [["-v"], "status", ["-h", "-v"]]
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should work when given only a subcommand and args" do
|
131
|
+
result = instance.split_main_and_subcommand(["status", "-h"])
|
132
|
+
result.should == [[], "status", ["-h"]]
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should work when given only main flags" do
|
136
|
+
result = instance.split_main_and_subcommand(["-v", "-h"])
|
137
|
+
result.should == [["-v", "-h"], nil, []]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should work when given only a subcommand" do
|
141
|
+
result = instance.split_main_and_subcommand(["status"])
|
142
|
+
result.should == [[], "status", []]
|
143
|
+
end
|
144
|
+
|
145
|
+
it "works when there are other non-flag args after the subcommand" do
|
146
|
+
result = instance.split_main_and_subcommand(["-v", "box", "add", "-h"])
|
147
|
+
result.should == [["-v"], "box", ["add", "-h"]]
|
21
148
|
end
|
22
149
|
end
|
23
150
|
end
|
@@ -1,52 +1,25 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
@klass = Vagrant::Config::Base
|
6
|
-
end
|
3
|
+
describe Vagrant::Config::Base do
|
4
|
+
include_context "unit"
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Vagrant::Config::Top.expects(:configures).with(acc, klass)
|
13
|
-
klass.configures(acc)
|
6
|
+
let(:foo_class) do
|
7
|
+
Class.new(described_class) do
|
8
|
+
attr_accessor :one
|
9
|
+
attr_accessor :two
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
should "return a hash of instance variables" do
|
23
|
-
data = { "foo" => "bar", "bar" => "baz" }
|
24
|
-
|
25
|
-
data.each do |iv, value|
|
26
|
-
@base.instance_variable_set("@#{iv}".to_sym, value)
|
27
|
-
end
|
13
|
+
it "should merge by default by simply copying each instance variable" do
|
14
|
+
one = foo_class.new
|
15
|
+
one.one = 2
|
16
|
+
one.two = 1
|
28
17
|
|
29
|
-
|
30
|
-
|
18
|
+
two = foo_class.new
|
19
|
+
two.two = 5
|
31
20
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
context "converting to JSON" do
|
38
|
-
should "include magic `json_class`" do
|
39
|
-
@iv_hash = { "foo" => "bar" }
|
40
|
-
@base.expects(:instance_variables_hash).returns(@iv_hash)
|
41
|
-
@json = { 'json_class' => @base.class.name }.merge(@iv_hash).to_json
|
42
|
-
assert_equal @json, @base.to_json
|
43
|
-
end
|
44
|
-
|
45
|
-
should "not include top in the JSON hash" do
|
46
|
-
@base.top = "FOO"
|
47
|
-
hash = @base.instance_variables_hash
|
48
|
-
assert !hash.has_key?(:top)
|
49
|
-
end
|
50
|
-
end
|
21
|
+
result = one.merge(two)
|
22
|
+
result.one.should == 2
|
23
|
+
result.two.should == 5
|
51
24
|
end
|
52
25
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
|
+
|
3
|
+
describe Vagrant::Config::Loader do
|
4
|
+
include_context "unit"
|
5
|
+
|
6
|
+
let(:instance) { described_class.new }
|
7
|
+
|
8
|
+
it "should ignore non-existent load order keys" do
|
9
|
+
instance.load_order = [:foo]
|
10
|
+
instance.load
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should load and return the configuration" do
|
14
|
+
proc = Proc.new do |config|
|
15
|
+
config.vagrant.dotfile_name = "foo"
|
16
|
+
end
|
17
|
+
|
18
|
+
instance.load_order = [:proc]
|
19
|
+
instance.set(:proc, proc)
|
20
|
+
config = instance.load
|
21
|
+
|
22
|
+
config.vagrant.dotfile_name.should == "foo"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should only run the same proc once" do
|
26
|
+
count = 0
|
27
|
+
proc = Proc.new do |config|
|
28
|
+
config.vagrant.dotfile_name = "foo"
|
29
|
+
count += 1
|
30
|
+
end
|
31
|
+
|
32
|
+
instance.load_order = [:proc]
|
33
|
+
instance.set(:proc, proc)
|
34
|
+
|
35
|
+
5.times do
|
36
|
+
result = instance.load
|
37
|
+
|
38
|
+
# Verify the config result
|
39
|
+
result.vagrant.dotfile_name.should == "foo"
|
40
|
+
|
41
|
+
# Verify the count is only one
|
42
|
+
count.should == 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should only load configuration files once" do
|
47
|
+
$_config_data = 0
|
48
|
+
|
49
|
+
# We test both setting a file multiple times as well as multiple
|
50
|
+
# loads, since both should not cache the data.
|
51
|
+
file = temporary_file("$_config_data += 1")
|
52
|
+
instance.load_order = [:file]
|
53
|
+
5.times { instance.set(:file, file) }
|
54
|
+
5.times { instance.load }
|
55
|
+
|
56
|
+
$_config_data.should == 1
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not clear the cache if setting to the same value multiple times" do
|
60
|
+
$_config_data = 0
|
61
|
+
|
62
|
+
file = temporary_file("$_config_data += 1")
|
63
|
+
|
64
|
+
instance.load_order = [:proc]
|
65
|
+
instance.set(:proc, file)
|
66
|
+
5.times { instance.load }
|
67
|
+
|
68
|
+
instance.set(:proc, file)
|
69
|
+
5.times { instance.load }
|
70
|
+
|
71
|
+
$_config_data.should == 1
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should raise proper error if there is a syntax error in a Vagrantfile" do
|
75
|
+
instance.load_order = [:file]
|
76
|
+
expect { instance.set(:file, temporary_file("Vagrant:^Config")) }.
|
77
|
+
to raise_exception(Vagrant::Errors::VagrantfileSyntaxError)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
|
+
|
3
|
+
require "vagrant/registry"
|
4
|
+
|
5
|
+
describe Vagrant::Config::Top do
|
6
|
+
include_context "unit"
|
7
|
+
|
8
|
+
let(:registry) { Vagrant::Registry.new }
|
9
|
+
let(:instance) { described_class.new(registry) }
|
10
|
+
|
11
|
+
it "should load in the proper config class" do
|
12
|
+
registry.register(:foo, Object)
|
13
|
+
|
14
|
+
instance.foo.should be_kind_of(Object)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should load the proper config class only once" do
|
18
|
+
registry.register(:foo, Object)
|
19
|
+
|
20
|
+
obj = instance.foo
|
21
|
+
instance.foo.should eql(obj)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "still raises a method missing error if invalid key" do
|
25
|
+
expect { instance.foo }.to raise_error(NoMethodError)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "merging" do
|
29
|
+
let(:foo_class) do
|
30
|
+
Class.new do
|
31
|
+
attr_accessor :one
|
32
|
+
attr_accessor :two
|
33
|
+
|
34
|
+
def merge(other)
|
35
|
+
result = self.class.new
|
36
|
+
result.one = other.one || one
|
37
|
+
result.two = other.two || two
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "merges each key by calling `merge` on the class" do
|
44
|
+
registry.register(:foo, foo_class)
|
45
|
+
|
46
|
+
instance.foo.one = 1
|
47
|
+
instance.foo.two = 2
|
48
|
+
|
49
|
+
another = described_class.new(registry)
|
50
|
+
another.foo.one = 2
|
51
|
+
|
52
|
+
result = instance.merge(another)
|
53
|
+
result.foo.one.should == 2
|
54
|
+
result.foo.two.should == 2
|
55
|
+
end
|
56
|
+
|
57
|
+
it "merges keys that aren't in the source instance" do
|
58
|
+
reg = Vagrant::Registry.new
|
59
|
+
reg.register(:foo, foo_class)
|
60
|
+
|
61
|
+
another = described_class.new(reg)
|
62
|
+
another.foo.one = 2
|
63
|
+
|
64
|
+
result = instance.merge(another)
|
65
|
+
result.foo.one.should == 2
|
66
|
+
result.foo.two.should be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|