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
@@ -0,0 +1,105 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ActionWardenTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Action::Warden
|
6
|
+
@instance = @klass.new([], {})
|
7
|
+
end
|
8
|
+
|
9
|
+
context "initializing" do
|
10
|
+
should "finalize the middleware" do
|
11
|
+
middleware = [1,2,3]
|
12
|
+
middleware.each do |m|
|
13
|
+
@klass.any_instance.expects(:finalize_action).with(m, {}).returns(m)
|
14
|
+
end
|
15
|
+
@warden = @klass.new(middleware, new_env)
|
16
|
+
assert_equal @warden.actions, [1,2,3]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "setting up middleware" do
|
21
|
+
should "make non-classes lambdas" do
|
22
|
+
env = new_env
|
23
|
+
env.expects(:foo).once
|
24
|
+
|
25
|
+
func = lambda { |x| x.foo }
|
26
|
+
@instance.finalize_action(func, env).call(env)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "raise exception if given invalid middleware" do
|
30
|
+
assert_raises(RuntimeError) {
|
31
|
+
@instance.finalize_action(7, nil)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "calling" do
|
37
|
+
should "return if there are no actions to execute" do
|
38
|
+
@instance.actions.expects(:pop).never
|
39
|
+
assert !@instance.call(new_env)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "move the last action to the front of the stack" do
|
43
|
+
@instance.actions << lambda { |env| }
|
44
|
+
assert @instance.stack.empty?
|
45
|
+
@instance.call(new_env)
|
46
|
+
assert !@instance.stack.empty?
|
47
|
+
assert @instance.actions.empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
should "call the next action" do
|
51
|
+
action = mock('action')
|
52
|
+
action.expects(:call).with({})
|
53
|
+
@instance.actions << action
|
54
|
+
@instance.call(new_env)
|
55
|
+
end
|
56
|
+
|
57
|
+
should "begin recovery sequence when the called action raises an exception" do
|
58
|
+
class Foo
|
59
|
+
def initialize(*args); end
|
60
|
+
def call(env)
|
61
|
+
raise "An exception"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
@instance.actions << Foo.new
|
66
|
+
@instance.expects(:begin_rescue).with() do |env|
|
67
|
+
assert env["vagrant.error"].is_a?(RuntimeError)
|
68
|
+
true
|
69
|
+
end
|
70
|
+
assert_raises(RuntimeError) { @instance.call(new_env) }
|
71
|
+
end
|
72
|
+
|
73
|
+
should "raise interrupt if the environment is interupted" do
|
74
|
+
env = new_env
|
75
|
+
env.expects(:interrupted?).returns(true)
|
76
|
+
@instance.actions << lambda { |env| }
|
77
|
+
|
78
|
+
assert_raises(Vagrant::Errors::VagrantInterrupt) {
|
79
|
+
@instance.call(env)
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "recover" do
|
85
|
+
should "call recover on all items in the stack" do
|
86
|
+
seq = sequence("sequence")
|
87
|
+
@instance.stack = [rescueable_mock("action"), rescueable_mock("another")]
|
88
|
+
@instance.stack.each do |action|
|
89
|
+
action.expects(:recover).with(new_env).in_sequence(seq)
|
90
|
+
end
|
91
|
+
|
92
|
+
@instance.begin_rescue(new_env)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def new_env
|
97
|
+
Vagrant::Action::Environment.new(nil)
|
98
|
+
end
|
99
|
+
|
100
|
+
def rescueable_mock(name)
|
101
|
+
mock_action = mock(name)
|
102
|
+
mock_action.stubs(:respond_to?).with(:recover).returns(true)
|
103
|
+
mock_action
|
104
|
+
end
|
105
|
+
end
|
data/test/vagrant/action_test.rb
CHANGED
@@ -7,7 +7,7 @@ class ActionTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
context "with a class" do
|
9
9
|
teardown do
|
10
|
-
@klass.actions.
|
10
|
+
@klass.actions.delete(:foo)
|
11
11
|
end
|
12
12
|
|
13
13
|
should "be able to register an action" do
|
@@ -24,16 +24,12 @@ class ActionTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
context "with an instance" do
|
26
26
|
setup do
|
27
|
-
@instance = @klass.new(
|
28
|
-
end
|
29
|
-
|
30
|
-
teardown do
|
31
|
-
@klass.actions.clear
|
27
|
+
@instance = @klass.new(vagrant_env)
|
32
28
|
end
|
33
29
|
|
34
30
|
should "raise an exception if a nil action is given" do
|
35
|
-
assert_raises(
|
36
|
-
assert_raises(
|
31
|
+
assert_raises(ArgumentError) { @instance.run(nil) }
|
32
|
+
assert_raises(ArgumentError) { @instance.run(:dontexist) }
|
37
33
|
end
|
38
34
|
|
39
35
|
should "run the callable item with the proper context" do
|
@@ -74,6 +70,7 @@ class ActionTest < Test::Unit::TestCase
|
|
74
70
|
|
75
71
|
@klass.register(:call, callable)
|
76
72
|
@instance.run(:call)
|
73
|
+
@klass.actions.delete(:call)
|
77
74
|
end
|
78
75
|
|
79
76
|
should "run the given class if a class is given" do
|
@@ -88,24 +85,5 @@ class ActionTest < Test::Unit::TestCase
|
|
88
85
|
|
89
86
|
@instance.run(callable, :bar => :foo)
|
90
87
|
end
|
91
|
-
|
92
|
-
should "exit if environment was marked as interrupted" do
|
93
|
-
callable = lambda do |env|
|
94
|
-
env.error!(:interrupt)
|
95
|
-
end
|
96
|
-
|
97
|
-
@instance.stubs(:error_and_exit)
|
98
|
-
@instance.expects(:exit).once
|
99
|
-
@instance.run(callable)
|
100
|
-
end
|
101
|
-
|
102
|
-
should "error and exit if erroneous environment results" do
|
103
|
-
callable = lambda do |env|
|
104
|
-
env.error!(:key, :foo => :bar)
|
105
|
-
end
|
106
|
-
|
107
|
-
@instance.expects(:error_and_exit).with(:key, :foo => :bar)
|
108
|
-
@instance.run(callable)
|
109
|
-
end
|
110
88
|
end
|
111
89
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class BoxCollectionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
clean_paths
|
6
|
+
|
7
|
+
@klass = Vagrant::BoxCollection
|
8
|
+
end
|
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_equal 2, result.length
|
17
|
+
assert_equal ["bar", "foo"], names
|
18
|
+
end
|
19
|
+
|
20
|
+
should "reload the box list" do
|
21
|
+
instance = @klass.new(vagrant_env)
|
22
|
+
assert instance.empty?
|
23
|
+
|
24
|
+
vagrant_box("foo")
|
25
|
+
|
26
|
+
instance.reload!
|
27
|
+
assert !instance.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
should "find a specific box" do
|
31
|
+
vagrant_box("foo")
|
32
|
+
vagrant_box("bar")
|
33
|
+
|
34
|
+
instance = @klass.new(vagrant_env)
|
35
|
+
result = instance.find("foo")
|
36
|
+
assert result
|
37
|
+
assert_equal "foo", result.name
|
38
|
+
end
|
39
|
+
|
40
|
+
should "return nil if it couldn't find a specific box" do
|
41
|
+
instance = @klass.new(vagrant_env)
|
42
|
+
assert_nil instance.find("thisshouldnotexist")
|
43
|
+
end
|
44
|
+
end
|
data/test/vagrant/box_test.rb
CHANGED
@@ -3,81 +3,7 @@ require "test_helper"
|
|
3
3
|
class BoxTest < Test::Unit::TestCase
|
4
4
|
context "class methods" do
|
5
5
|
setup do
|
6
|
-
@env =
|
7
|
-
end
|
8
|
-
|
9
|
-
context "listing all boxes" do
|
10
|
-
setup do
|
11
|
-
Dir.stubs(:open)
|
12
|
-
File.stubs(:directory?).returns(true)
|
13
|
-
|
14
|
-
@boxes_path = "foo"
|
15
|
-
@env.stubs(:boxes_path).returns(@boxes_path)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "open the boxes directory" do
|
19
|
-
Dir.expects(:open).with(@env.boxes_path)
|
20
|
-
Vagrant::Box.all(@env)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "return an array" do
|
24
|
-
result = Vagrant::Box.all(@env)
|
25
|
-
assert result.is_a?(Array)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "not return the '.' and '..' directories" do
|
29
|
-
dir = [".", "..", "..", ".", ".."]
|
30
|
-
Dir.expects(:open).yields(dir)
|
31
|
-
result = Vagrant::Box.all(@env)
|
32
|
-
assert result.empty?
|
33
|
-
end
|
34
|
-
|
35
|
-
should "return the other directories" do
|
36
|
-
dir = [".", "foo", "bar", "baz"]
|
37
|
-
Dir.expects(:open).yields(dir)
|
38
|
-
result = Vagrant::Box.all(@env)
|
39
|
-
assert_equal ["foo", "bar", "baz"], result
|
40
|
-
end
|
41
|
-
|
42
|
-
should "ignore the files" do
|
43
|
-
dir = ["foo", "bar"]
|
44
|
-
files = [true, false]
|
45
|
-
Dir.expects(:open).yields(dir)
|
46
|
-
dir_sequence = sequence("directory")
|
47
|
-
dir.each_with_index do |dir, index|
|
48
|
-
File.expects(:directory?).with(File.join(@boxes_path, dir)).returns(files[index]).in_sequence(dir_sequence)
|
49
|
-
end
|
50
|
-
|
51
|
-
result = Vagrant::Box.all(@env)
|
52
|
-
assert_equal ["foo"], result
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "finding" do
|
57
|
-
setup do
|
58
|
-
@dir = "foo"
|
59
|
-
@name = "bar"
|
60
|
-
Vagrant::Box.stubs(:directory).with(@env, @name).returns(@dir)
|
61
|
-
end
|
62
|
-
|
63
|
-
should "return nil if the box doesn't exist" do
|
64
|
-
File.expects(:directory?).with(@dir).once.returns(false)
|
65
|
-
assert_nil Vagrant::Box.find(@env, @name)
|
66
|
-
end
|
67
|
-
|
68
|
-
should "return a box object with the proper name set" do
|
69
|
-
File.expects(:directory?).with(@dir).once.returns(true)
|
70
|
-
result = Vagrant::Box.find(@env, @name)
|
71
|
-
assert result
|
72
|
-
assert_equal @name, result.name
|
73
|
-
end
|
74
|
-
|
75
|
-
should "return a box object with the proper env set" do
|
76
|
-
File.expects(:directory?).with(@dir).once.returns(true)
|
77
|
-
result = Vagrant::Box.find(@env, @name)
|
78
|
-
assert result
|
79
|
-
assert_equal @env, result.env
|
80
|
-
end
|
6
|
+
@env = vagrant_env
|
81
7
|
end
|
82
8
|
|
83
9
|
context "adding" do
|
@@ -88,31 +14,17 @@ class BoxTest < Test::Unit::TestCase
|
|
88
14
|
|
89
15
|
should "create a new instance, set the variables, and add it" do
|
90
16
|
box = mock("box")
|
91
|
-
box.expects(:name=).with(@name)
|
92
17
|
box.expects(:uri=).with(@uri)
|
93
|
-
box.expects(:env=).with(@env)
|
94
18
|
box.expects(:add).once
|
95
|
-
Vagrant::Box.expects(:new).returns(box)
|
19
|
+
Vagrant::Box.expects(:new).with(@env, @name).returns(box)
|
96
20
|
Vagrant::Box.add(@env, @name, @uri)
|
97
21
|
end
|
98
22
|
end
|
99
|
-
|
100
|
-
context "box directory" do
|
101
|
-
setup do
|
102
|
-
@name = "foo"
|
103
|
-
@box_dir = File.join(@env.boxes_path, @name)
|
104
|
-
end
|
105
|
-
|
106
|
-
should "return the boxes_path joined with the name" do
|
107
|
-
assert_equal @box_dir, Vagrant::Box.directory(@env, @name)
|
108
|
-
end
|
109
|
-
end
|
110
23
|
end
|
111
24
|
|
112
25
|
context "instance methods" do
|
113
26
|
setup do
|
114
|
-
@box = Vagrant::Box.new
|
115
|
-
@box.env = mock_environment
|
27
|
+
@box = Vagrant::Box.new(vagrant_env, "foo")
|
116
28
|
end
|
117
29
|
|
118
30
|
should "execute the Add action when add is called" do
|
@@ -121,14 +33,8 @@ class BoxTest < Test::Unit::TestCase
|
|
121
33
|
end
|
122
34
|
|
123
35
|
context "box directory" do
|
124
|
-
setup do
|
125
|
-
@box.name = "foo"
|
126
|
-
end
|
127
|
-
|
128
36
|
should "return the boxes_path joined with the name" do
|
129
|
-
|
130
|
-
Vagrant::Box.expects(:directory).with(@box.env, @box.name).returns(result)
|
131
|
-
assert result.equal?(@box.directory)
|
37
|
+
assert_equal @box.env.boxes_path.join(@box.name), @box.directory
|
132
38
|
end
|
133
39
|
end
|
134
40
|
|
@@ -152,14 +58,8 @@ class BoxTest < Test::Unit::TestCase
|
|
152
58
|
end
|
153
59
|
|
154
60
|
context "ovf file" do
|
155
|
-
setup do
|
156
|
-
@box.stubs(:directory).returns("foo")
|
157
|
-
|
158
|
-
@box.env.config.vm.box_ovf = "foo.ovf"
|
159
|
-
end
|
160
|
-
|
161
61
|
should "be the directory joined with the config ovf file" do
|
162
|
-
assert_equal
|
62
|
+
assert_equal @box.directory.join(@box.env.config.vm.box_ovf), @box.ovf_file
|
163
63
|
end
|
164
64
|
end
|
165
65
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CLITest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::CLI
|
6
|
+
end
|
7
|
+
|
8
|
+
context "registering" do
|
9
|
+
should "register a base command as a single invokable" do
|
10
|
+
base = Class.new(Vagrant::Command::Base)
|
11
|
+
name = "__test_registering_single_subcommand"
|
12
|
+
@klass.register(base, name, name, "A description")
|
13
|
+
assert @klass.tasks[name]
|
14
|
+
end
|
15
|
+
|
16
|
+
should "register a group base as a subcommand" do
|
17
|
+
base = Class.new(Vagrant::Command::GroupBase)
|
18
|
+
name = "_test_registering_single_group"
|
19
|
+
@klass.register(base, name, name, "A description")
|
20
|
+
assert @klass.subcommands.include?(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "alias methods if the alias option is given" do
|
24
|
+
base = Class.new(Vagrant::Command::Base) do
|
25
|
+
def execute
|
26
|
+
raise "WORKED"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
name = "__test_registering_with_alias"
|
31
|
+
@klass.register(base, name, name, "A description", :alias => "--ALIAS")
|
32
|
+
assert_raises(RuntimeError) { @klass.start(["--ALIAS"], :env => vagrant_env) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandBaseTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Command::Base
|
6
|
+
@env = vagrant_env
|
7
|
+
end
|
8
|
+
|
9
|
+
context "initialization" do
|
10
|
+
should "require an environment" do
|
11
|
+
assert_raises(Vagrant::Errors::CLIMissingEnvironment) { @klass.new([], {}, {}) }
|
12
|
+
assert_nothing_raised { @klass.new([], {}, { :env => @env }) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "extracting a name from a usage string" do
|
17
|
+
should "extract properly" do
|
18
|
+
assert_equal "init", @klass.extract_name_from_usage("init")
|
19
|
+
assert_equal "init", @klass.extract_name_from_usage("init [foo] [bar]")
|
20
|
+
assert_equal "ssh-config", @klass.extract_name_from_usage("ssh-config")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CommandGroupBaseTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Command::GroupBase
|
6
|
+
@env = vagrant_env
|
7
|
+
end
|
8
|
+
|
9
|
+
context "initialization" do
|
10
|
+
should "require an environment" do
|
11
|
+
assert_raises(Vagrant::Errors::CLIMissingEnvironment) { @klass.new([], {}, {}) }
|
12
|
+
assert_nothing_raised { @klass.new([], {}, { :env => @env }) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|