fixed-vagrant 0.7.4.dev
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +272 -0
- data/Gemfile +21 -0
- data/LICENSE +21 -0
- data/README.md +75 -0
- data/Rakefile +22 -0
- data/bin/vagrant +22 -0
- data/config/default.rb +39 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.ppk +26 -0
- data/keys/vagrant.pub +1 -0
- data/lib/vagrant.rb +42 -0
- data/lib/vagrant/action.rb +134 -0
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/box/destroy.rb +21 -0
- data/lib/vagrant/action/box/download.rb +72 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +55 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +124 -0
- data/lib/vagrant/action/builtin.rb +104 -0
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +50 -0
- data/lib/vagrant/action/general.rb +8 -0
- data/lib/vagrant/action/general/package.rb +109 -0
- data/lib/vagrant/action/general/validate.rb +19 -0
- data/lib/vagrant/action/vm.rb +31 -0
- data/lib/vagrant/action/vm/boot.rb +48 -0
- data/lib/vagrant/action/vm/check_box.rb +28 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +30 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +30 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +52 -0
- data/lib/vagrant/action/vm/forward_ports.rb +134 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +29 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +35 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +139 -0
- data/lib/vagrant/action/vm/nfs.rb +159 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +33 -0
- data/lib/vagrant/action/vm/provision.rb +41 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/share_folders.rb +70 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +79 -0
- data/lib/vagrant/box.rb +90 -0
- data/lib/vagrant/box_collection.rb +53 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command.rb +25 -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 +107 -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 +42 -0
- data/lib/vagrant/command/ssh_config.rb +26 -0
- data/lib/vagrant/command/status.rb +22 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +19 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +123 -0
- data/lib/vagrant/config/base.rb +85 -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 +33 -0
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +16 -0
- data/lib/vagrant/config/vm.rb +137 -0
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +70 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +23 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +64 -0
- data/lib/vagrant/environment.rb +392 -0
- data/lib/vagrant/errors.rb +332 -0
- data/lib/vagrant/hosts.rb +8 -0
- data/lib/vagrant/hosts/arch.rb +27 -0
- data/lib/vagrant/hosts/base.rb +78 -0
- data/lib/vagrant/hosts/bsd.rb +52 -0
- data/lib/vagrant/hosts/linux.rb +47 -0
- data/lib/vagrant/plugin.rb +57 -0
- data/lib/vagrant/provisioners.rb +9 -0
- data/lib/vagrant/provisioners/base.rb +63 -0
- data/lib/vagrant/provisioners/chef.rb +130 -0
- data/lib/vagrant/provisioners/chef_server.rb +103 -0
- data/lib/vagrant/provisioners/chef_solo.rb +142 -0
- data/lib/vagrant/provisioners/puppet.rb +137 -0
- data/lib/vagrant/provisioners/puppet_server.rb +55 -0
- data/lib/vagrant/provisioners/shell.rb +52 -0
- data/lib/vagrant/ssh.rb +173 -0
- data/lib/vagrant/ssh/session.rb +125 -0
- data/lib/vagrant/systems.rb +11 -0
- data/lib/vagrant/systems/base.rb +87 -0
- data/lib/vagrant/systems/debian.rb +36 -0
- data/lib/vagrant/systems/freebsd.rb +84 -0
- data/lib/vagrant/systems/gentoo.rb +27 -0
- data/lib/vagrant/systems/linux.rb +83 -0
- data/lib/vagrant/systems/linux/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/redhat.rb +39 -0
- data/lib/vagrant/systems/solaris.rb +62 -0
- data/lib/vagrant/systems/ubuntu.rb +17 -0
- data/lib/vagrant/test_helpers.rb +128 -0
- data/lib/vagrant/ui.rb +69 -0
- data/lib/vagrant/util.rb +13 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +25 -0
- data/lib/vagrant/util/platform.rb +65 -0
- data/lib/vagrant/util/resource_logger.rb +63 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +177 -0
- data/templates/chef_server_client.erb +18 -0
- data/templates/chef_solo_solo.erb +19 -0
- data/templates/commands/init/Vagrantfile.erb +82 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +535 -0
- data/templates/network_entry_debian.erb +8 -0
- data/templates/network_entry_gentoo.erb +5 -0
- data/templates/network_entry_redhat.erb +8 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/ssh_config.erb +9 -0
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +26 -0
- data/test/vagrant/action/box/destroy_test.rb +18 -0
- data/test/vagrant/action/box/download_test.rb +125 -0
- data/test/vagrant/action/box/package_test.rb +25 -0
- data/test/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/vagrant/action/box/verify_test.rb +30 -0
- data/test/vagrant/action/builder_test.rb +203 -0
- data/test/vagrant/action/env/set_test.rb +24 -0
- data/test/vagrant/action/environment_test.rb +27 -0
- data/test/vagrant/action/general/package_test.rb +268 -0
- data/test/vagrant/action/general/validate_test.rb +31 -0
- data/test/vagrant/action/vm/boot_test.rb +66 -0
- data/test/vagrant/action/vm/check_box_test.rb +56 -0
- data/test/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +84 -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 +30 -0
- data/test/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/vagrant/action/vm/export_test.rb +107 -0
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +70 -0
- data/test/vagrant/action/vm/forward_ports_test.rb +194 -0
- data/test/vagrant/action/vm/halt_test.rb +79 -0
- data/test/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/vagrant/action/vm/import_test.rb +66 -0
- data/test/vagrant/action/vm/match_mac_address_test.rb +36 -0
- data/test/vagrant/action/vm/network_test.rb +286 -0
- data/test/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/vagrant/action/vm/nfs_test.rb +260 -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/provision_test.rb +90 -0
- data/test/vagrant/action/vm/resume_test.rb +35 -0
- data/test/vagrant/action/vm/share_folders_test.rb +139 -0
- data/test/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/vagrant/action/warden_test.rb +119 -0
- data/test/vagrant/action_test.rb +89 -0
- data/test/vagrant/box_collection_test.rb +45 -0
- data/test/vagrant/box_test.rb +74 -0
- 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/command/package_test.rb +27 -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 +35 -0
- data/test/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/vagrant/config/vm_test.rb +86 -0
- data/test/vagrant/config_test.rb +162 -0
- data/test/vagrant/data_store_test.rb +77 -0
- data/test/vagrant/downloaders/base_test.rb +28 -0
- data/test/vagrant/downloaders/file_test.rb +48 -0
- data/test/vagrant/downloaders/http_test.rb +80 -0
- data/test/vagrant/environment_test.rb +508 -0
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +46 -0
- data/test/vagrant/hosts/bsd_test.rb +53 -0
- data/test/vagrant/hosts/linux_test.rb +54 -0
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +63 -0
- data/test/vagrant/provisioners/chef_server_test.rb +188 -0
- data/test/vagrant/provisioners/chef_solo_test.rb +219 -0
- data/test/vagrant/provisioners/chef_test.rb +179 -0
- data/test/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/vagrant/provisioners/shell_test.rb +68 -0
- data/test/vagrant/ssh/session_test.rb +40 -0
- data/test/vagrant/ssh_test.rb +342 -0
- data/test/vagrant/systems/base_test.rb +18 -0
- data/test/vagrant/systems/linux_test.rb +114 -0
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/busy_test.rb +106 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -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 +78 -0
- data/test/vagrant/util/retryable_test.rb +50 -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/vm_test.rb +291 -0
- data/vagrant.gemspec +36 -0
- metadata +514 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigErrorsTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Config::ErrorRecorder
|
6
|
+
@instance = @klass.new
|
7
|
+
end
|
8
|
+
|
9
|
+
should "not have any errors to start" do
|
10
|
+
assert @instance.errors.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
should "add errors" do
|
14
|
+
key = "vagrant.test.errors.test_key"
|
15
|
+
@instance.add(key)
|
16
|
+
assert_equal key, @instance.errors.first
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigSSHTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@env = vagrant_env
|
6
|
+
end
|
7
|
+
|
8
|
+
should "expand any path when requesting the value" do
|
9
|
+
result = File.expand_path(@env.config.ssh.private_key_path, @env.root_path)
|
10
|
+
assert_equal result, @env.config.ssh.private_key_path
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigVagrantTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@config = Vagrant::Config::VagrantConfig.new
|
6
|
+
end
|
7
|
+
|
8
|
+
context "validation" do
|
9
|
+
setup do
|
10
|
+
@config.dotfile_name = "foo"
|
11
|
+
@config.host = "foo"
|
12
|
+
|
13
|
+
@errors = Vagrant::Config::ErrorRecorder.new
|
14
|
+
end
|
15
|
+
|
16
|
+
should "be valid with given set of values" do
|
17
|
+
@config.validate(@errors)
|
18
|
+
assert @errors.errors.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be invalid with no dotfile" do
|
22
|
+
@config.dotfile_name = nil
|
23
|
+
|
24
|
+
@config.validate(@errors)
|
25
|
+
assert !@errors.errors.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
should "be invalid with no host" do
|
29
|
+
@config.host = nil
|
30
|
+
|
31
|
+
@config.validate(@errors)
|
32
|
+
assert !@errors.errors.empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigVMProvisionerTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Config::VMConfig::Provisioner
|
6
|
+
@top = Vagrant::Config::Top.new(nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "initializing" do
|
10
|
+
should "expose the top instance that the provisioner belongs to" do
|
11
|
+
instance = @klass.new(@top, :chef_solo)
|
12
|
+
assert_equal @top, instance.top
|
13
|
+
end
|
14
|
+
|
15
|
+
should "expose the shortcut used" do
|
16
|
+
instance = @klass.new(@top, :chef_solo)
|
17
|
+
assert_equal :chef_solo, instance.shortcut
|
18
|
+
end
|
19
|
+
|
20
|
+
should "expose the provisioner class if its a valid shortcut" do
|
21
|
+
instance = @klass.new(@top, :chef_solo)
|
22
|
+
assert_equal Vagrant::Provisioners::ChefSolo, instance.provisioner
|
23
|
+
end
|
24
|
+
|
25
|
+
should "expose the provisioner class if its a valid class" do
|
26
|
+
instance = @klass.new(@top, Vagrant::Provisioners::ChefSolo)
|
27
|
+
assert_equal Vagrant::Provisioners::ChefSolo, instance.provisioner
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have a nil provisioner class if invalid" do
|
31
|
+
instance = @klass.new(@top, :i_shall_never_exist)
|
32
|
+
assert_nil instance.provisioner
|
33
|
+
end
|
34
|
+
|
35
|
+
should "have a nil config instance if invalid" do
|
36
|
+
instance = @klass.new(@top, :i_shall_never_exist)
|
37
|
+
assert_nil instance.config
|
38
|
+
end
|
39
|
+
|
40
|
+
should "set the top of the config object to the given top" do
|
41
|
+
instance = @klass.new(@top, :chef_solo)
|
42
|
+
assert_equal @top, instance.config.top
|
43
|
+
end
|
44
|
+
|
45
|
+
should "configure the provisioner if valid" do
|
46
|
+
instance = @klass.new(@top, :chef_solo) do |chef|
|
47
|
+
chef.cookbooks_path = "foo"
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal "foo", instance.config.cookbooks_path
|
51
|
+
end
|
52
|
+
|
53
|
+
should "configure the provisioner with a hash if valid" do
|
54
|
+
instance = @klass.new(@top, :chef_solo, :cookbooks_path => "foo")
|
55
|
+
assert_equal "foo", instance.config.cookbooks_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "validation" do
|
60
|
+
setup do
|
61
|
+
@errors = Vagrant::Config::ErrorRecorder.new
|
62
|
+
end
|
63
|
+
|
64
|
+
should "be invalid if provisioner is valid" do
|
65
|
+
instance = @klass.new(@top, :i_shall_never_exist)
|
66
|
+
instance.validate(@errors)
|
67
|
+
assert !@errors.errors.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
should "be invalid if provisioner doesn't inherit from provisioners base" do
|
71
|
+
klass = Class.new
|
72
|
+
instance = @klass.new(@top, klass)
|
73
|
+
instance.validate(@errors)
|
74
|
+
assert !@errors.errors.empty?
|
75
|
+
end
|
76
|
+
|
77
|
+
should "be valid with a valid provisioner" do
|
78
|
+
instance = @klass.new(@top, :chef_solo) do |chef|
|
79
|
+
chef.add_recipe "foo"
|
80
|
+
end
|
81
|
+
|
82
|
+
instance.validate(@errors)
|
83
|
+
assert @errors.errors.empty?
|
84
|
+
end
|
85
|
+
|
86
|
+
should "be invalid if a provisioner's config is invalid" do
|
87
|
+
instance = @klass.new(@top, :chef_solo)
|
88
|
+
instance.validate(@errors)
|
89
|
+
assert !@errors.errors.empty?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigVMTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@username = "mitchellh"
|
6
|
+
|
7
|
+
@env = vagrant_env
|
8
|
+
@config = @env.config.vm
|
9
|
+
@env.config.ssh.username = @username
|
10
|
+
end
|
11
|
+
|
12
|
+
context "defining VMs" do
|
13
|
+
should "store the proc by name but not run it" do
|
14
|
+
foo = mock("proc")
|
15
|
+
foo.expects(:call).never
|
16
|
+
|
17
|
+
proc = Proc.new { foo.call }
|
18
|
+
@config.define(:name, &proc)
|
19
|
+
assert @config.defined_vms[:name].proc_stack.include?(proc)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "store the options" do
|
23
|
+
@config.define(:name, :set => true)
|
24
|
+
assert @config.defined_vms[:name].options[:set]
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not have multi-VMs by default" do
|
28
|
+
assert !@config.has_multi_vms?
|
29
|
+
end
|
30
|
+
|
31
|
+
should "have multi-VMs once one is specified" do
|
32
|
+
@config.define(:foo) {}
|
33
|
+
assert @config.has_multi_vms?
|
34
|
+
end
|
35
|
+
|
36
|
+
should "retain vm definition order" do
|
37
|
+
@config.define(:a) {}
|
38
|
+
@config.define(:b) {}
|
39
|
+
@config.define(:c) {}
|
40
|
+
|
41
|
+
assert_equal [:a, :b, :c], @config.defined_vm_keys
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "customizing" do
|
46
|
+
should "include the stacked proc runner module" do
|
47
|
+
assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner)
|
48
|
+
end
|
49
|
+
|
50
|
+
should "add the customize proc to the proc stack" do
|
51
|
+
proc = Proc.new {}
|
52
|
+
@config.customize(&proc)
|
53
|
+
assert @config.proc_stack.include?(proc)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "uid/gid" do
|
58
|
+
should "return the shared folder UID if set" do
|
59
|
+
@config.shared_folder_uid = "foo"
|
60
|
+
assert_equal "foo", @config.shared_folder_uid
|
61
|
+
end
|
62
|
+
|
63
|
+
should "return the SSH username if UID not set" do
|
64
|
+
@config.shared_folder_uid = nil
|
65
|
+
assert_equal @username, @config.shared_folder_uid
|
66
|
+
end
|
67
|
+
|
68
|
+
should "return the shared folder GID if set" do
|
69
|
+
@config.shared_folder_gid = "foo"
|
70
|
+
assert_equal "foo", @config.shared_folder_gid
|
71
|
+
end
|
72
|
+
|
73
|
+
should "return the SSH username if GID not set" do
|
74
|
+
@config.shared_folder_gid = nil
|
75
|
+
assert_equal @username, @config.shared_folder_gid
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "deprecated config" do
|
80
|
+
should "raise an error for provisioner=" do
|
81
|
+
assert_raises(Vagrant::Errors::VagrantError) {
|
82
|
+
@config.provisioner = :chef_solo
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ConfigTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Config
|
6
|
+
end
|
7
|
+
|
8
|
+
context "with the class" do
|
9
|
+
should "allow access to the last proc" do
|
10
|
+
foo = mock("object")
|
11
|
+
foo.expects(:call).once
|
12
|
+
|
13
|
+
@klass.run { |config| foo.call }
|
14
|
+
value = @klass.last_proc.first
|
15
|
+
assert value.is_a?(Proc)
|
16
|
+
value.call(nil)
|
17
|
+
|
18
|
+
assert @klass.last_proc.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with an instance" do
|
23
|
+
setup do
|
24
|
+
@instance = @klass.new
|
25
|
+
end
|
26
|
+
|
27
|
+
should "load the config files in the given order" do
|
28
|
+
names = %w{alpha beta gamma}
|
29
|
+
|
30
|
+
@instance.load_order = [:alpha, :beta]
|
31
|
+
|
32
|
+
names.each do |name|
|
33
|
+
vagrantfile(vagrant_box(name), "config.vm.box = '#{name}'")
|
34
|
+
@instance.set(name.to_sym, vagrant_box(name).join("Vagrantfile"))
|
35
|
+
end
|
36
|
+
|
37
|
+
config = @instance.load(nil)
|
38
|
+
assert_equal "beta", config.vm.box
|
39
|
+
end
|
40
|
+
|
41
|
+
should "load the config as procs" do
|
42
|
+
@instance.set(:proc, Proc.new { |config| config.vm.box = "proc" })
|
43
|
+
@instance.load_order = [:proc]
|
44
|
+
config = @instance.load(nil)
|
45
|
+
|
46
|
+
assert_equal "proc", config.vm.box
|
47
|
+
end
|
48
|
+
|
49
|
+
should "load an array of procs" do
|
50
|
+
@instance.set(:proc, [Proc.new { |config| config.vm.box = "proc" },
|
51
|
+
Proc.new { |config| config.vm.box = "proc2" }])
|
52
|
+
@instance.load_order = [:proc]
|
53
|
+
config = @instance.load(nil)
|
54
|
+
|
55
|
+
assert_equal "proc2", config.vm.box
|
56
|
+
end
|
57
|
+
|
58
|
+
should "not care if a file doesn't exist" do
|
59
|
+
@instance.load_order = [:foo]
|
60
|
+
assert_nothing_raised { @instance.set(:foo, "i/dont/exist") }
|
61
|
+
assert_nothing_raised { @instance.load(nil) }
|
62
|
+
end
|
63
|
+
|
64
|
+
should "not reload a file" do
|
65
|
+
foo_path = vagrant_box("foo").join("Vagrantfile")
|
66
|
+
|
67
|
+
vagrantfile(vagrant_box("foo"))
|
68
|
+
@instance.set(:foo, foo_path)
|
69
|
+
|
70
|
+
# Nothing should be raised in this case because the file isn't reloaded
|
71
|
+
vagrantfile(vagrant_box("foo"), "^%&8318")
|
72
|
+
assert_nothing_raised { @instance.set(:foo, foo_path) }
|
73
|
+
end
|
74
|
+
|
75
|
+
should "raise an exception if there is a syntax error in a file" do
|
76
|
+
vagrantfile(vagrant_box("foo"), "^%&8318")
|
77
|
+
|
78
|
+
assert_raises(Vagrant::Errors::VagrantfileSyntaxError) {
|
79
|
+
@instance.set(:foo, vagrant_box("foo").join("Vagrantfile"))
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "top config class" do
|
85
|
+
setup do
|
86
|
+
@configures_list = {}
|
87
|
+
@klass::Top.stubs(:configures_list).returns(@configures_list)
|
88
|
+
end
|
89
|
+
|
90
|
+
context "adding configure keys" do
|
91
|
+
setup do
|
92
|
+
@key = "top_config_foo"
|
93
|
+
@config_klass = mock("klass")
|
94
|
+
end
|
95
|
+
|
96
|
+
should "add key and klass to configures list" do
|
97
|
+
@klass::Top.configures(@key, @config_klass)
|
98
|
+
assert_equal @config_klass, @configures_list[@key]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "configuration keys on instance" do
|
103
|
+
setup do
|
104
|
+
@configures_list.clear
|
105
|
+
end
|
106
|
+
|
107
|
+
should "initialize each configurer and set it to its key" do
|
108
|
+
env = mock('env')
|
109
|
+
|
110
|
+
5.times do |i|
|
111
|
+
key = "key#{i}"
|
112
|
+
klass = mock("klass#{i}")
|
113
|
+
instance = mock("instance#{i}")
|
114
|
+
instance.expects(:top=).with() do |top|
|
115
|
+
assert top.is_a?(@klass::Top)
|
116
|
+
true
|
117
|
+
end
|
118
|
+
klass.expects(:new).returns(instance)
|
119
|
+
@configures_list[key] = klass
|
120
|
+
end
|
121
|
+
|
122
|
+
@klass::Top.new(env)
|
123
|
+
end
|
124
|
+
|
125
|
+
should "allow reading via methods" do
|
126
|
+
key = "my_foo_bar_key"
|
127
|
+
klass = mock("klass")
|
128
|
+
instance = mock("instance")
|
129
|
+
instance.stubs(:top=)
|
130
|
+
klass.expects(:new).returns(instance)
|
131
|
+
@klass::Top.configures(key, klass)
|
132
|
+
|
133
|
+
config = @klass::Top.new
|
134
|
+
assert_equal instance, config.send(key)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "validation" do
|
139
|
+
should "do nothing if no errors are added" do
|
140
|
+
valid_class = Class.new(@klass::Base)
|
141
|
+
@klass::Top.configures(:subconfig, valid_class)
|
142
|
+
instance = @klass::Top.new
|
143
|
+
assert_nothing_raised { instance.validate! }
|
144
|
+
end
|
145
|
+
|
146
|
+
should "raise an exception if there are errors" do
|
147
|
+
invalid_class = Class.new(@klass::Base) do
|
148
|
+
def validate(errors)
|
149
|
+
errors.add("vagrant.test.errors.test_key")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
@klass::Top.configures(:subconfig, invalid_class)
|
154
|
+
instance = @klass::Top.new
|
155
|
+
|
156
|
+
assert_raises(Vagrant::Errors::ConfigValidationFailed) {
|
157
|
+
instance.validate!
|
158
|
+
}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
class DataStoreTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@klass = Vagrant::DataStore
|
7
|
+
@initial_data = { "foo" => "bar" }
|
8
|
+
@db_file = File.join(tmp_path, "data_store_test")
|
9
|
+
File.open(@db_file, "w") { |f| f.write(@initial_data.to_json) }
|
10
|
+
|
11
|
+
@instance = @klass.new(@db_file)
|
12
|
+
end
|
13
|
+
|
14
|
+
teardown do
|
15
|
+
File.delete(@db_file) if File.exist?(@db_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "raise an exception if the db file is a directory" do
|
19
|
+
file = tmp_path.join("data_store_folder_test")
|
20
|
+
FileUtils.mkdir_p(file)
|
21
|
+
assert_raises (Vagrant::Errors::DotfileIsDirectory) {
|
22
|
+
@klass.new(file)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
should "be a hash with indifferent access" do
|
27
|
+
assert @instance.is_a?(Vagrant::Util::HashWithIndifferentAccess)
|
28
|
+
end
|
29
|
+
|
30
|
+
should "just be an empty hash if file doesn't exist" do
|
31
|
+
assert @klass.new("NEvERNENVENRNE").empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
should "read the data" do
|
35
|
+
assert_equal @initial_data["foo"], @instance[:foo]
|
36
|
+
end
|
37
|
+
|
38
|
+
should "read the data by stringifying keys" do
|
39
|
+
@instance[:bar] = { "baz" => "yay" }
|
40
|
+
@instance.commit
|
41
|
+
@instance = @klass.new(@db_file)
|
42
|
+
assert_equal "yay", @instance[:bar]["baz"]
|
43
|
+
end
|
44
|
+
|
45
|
+
should "write the data, but not save it right away" do
|
46
|
+
@instance[:foo] = "changed"
|
47
|
+
assert_equal "changed", @instance[:foo]
|
48
|
+
assert_equal @initial_data["foo"], @klass.new(@db_file)["foo"]
|
49
|
+
end
|
50
|
+
|
51
|
+
should "write the data if commit is called" do
|
52
|
+
@instance[:foo] = "changed"
|
53
|
+
@instance.commit
|
54
|
+
|
55
|
+
assert_equal "changed", @klass.new(@db_file)[:foo]
|
56
|
+
end
|
57
|
+
|
58
|
+
should "delete the data store file if the hash is empty" do
|
59
|
+
@instance[:foo] = :bar
|
60
|
+
@instance.commit
|
61
|
+
assert File.exist?(@db_file)
|
62
|
+
|
63
|
+
@instance.clear
|
64
|
+
assert @instance.empty?
|
65
|
+
@instance.commit
|
66
|
+
assert !File.exist?(@db_file)
|
67
|
+
end
|
68
|
+
|
69
|
+
should "clean nil and empties if commit is called" do
|
70
|
+
@instance[:foo] = { :bar => nil }
|
71
|
+
@instance[:bar] = {}
|
72
|
+
@instance.commit
|
73
|
+
|
74
|
+
assert !@instance.has_key?(:foo)
|
75
|
+
assert !@instance.has_key?(:bar)
|
76
|
+
end
|
77
|
+
end
|