vagrant 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +142 -108
- 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
@@ -1,47 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsReloadTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Reload
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@env.stubs(:require_root_path)
|
9
|
-
@instance = @klass.new(@env)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "executing" do
|
13
|
-
should "call all or single for the method" do
|
14
|
-
seq = sequence("seq")
|
15
|
-
@env.expects(:require_root_path).in_sequence(seq)
|
16
|
-
@instance.expects(:all_or_single).with([], :reload).in_sequence(seq)
|
17
|
-
@instance.execute
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "reloading a single VM" do
|
22
|
-
setup do
|
23
|
-
@foo_vm = mock("vm")
|
24
|
-
@foo_vm.stubs(:env).returns(@env)
|
25
|
-
vms = { :foo => @foo_vm }
|
26
|
-
@env.stubs(:vms).returns(vms)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "error and exit if the VM doesn't exist" do
|
30
|
-
@env.stubs(:vms).returns({})
|
31
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
32
|
-
@instance.reload_single(:foo)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "reload if its created" do
|
36
|
-
@foo_vm.stubs(:created?).returns(true)
|
37
|
-
@foo_vm.expects(:reload).once
|
38
|
-
@instance.execute(["foo"])
|
39
|
-
end
|
40
|
-
|
41
|
-
should "do nothing if its not created" do
|
42
|
-
@foo_vm.stubs(:created?).returns(false)
|
43
|
-
@foo_vm.expects(:reload).never
|
44
|
-
@instance.reload_single(:foo)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsResumeTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Resume
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "call all or single for the method" do
|
13
|
-
@instance.expects(:all_or_single).with([], :resume)
|
14
|
-
@instance.execute
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "resuming a single VM" do
|
19
|
-
setup do
|
20
|
-
@foo_vm = mock("vm")
|
21
|
-
@foo_vm.stubs(:env).returns(@env)
|
22
|
-
vms = { :foo => @foo_vm }
|
23
|
-
@env.stubs(:vms).returns(vms)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "error and exit if the VM doesn't exist" do
|
27
|
-
@env.stubs(:vms).returns({})
|
28
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
-
@instance.resume_single(:foo)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "resume if its created" do
|
33
|
-
@foo_vm.stubs(:created?).returns(true)
|
34
|
-
@foo_vm.expects(:resume).once
|
35
|
-
@instance.execute(["foo"])
|
36
|
-
end
|
37
|
-
|
38
|
-
should "do nothing if its not created" do
|
39
|
-
@foo_vm.stubs(:created?).returns(false)
|
40
|
-
@foo_vm.expects(:resume).never
|
41
|
-
@instance.resume_single(:foo)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsSSHConfigTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::SSHConfig
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@env.stubs(:require_root_path)
|
9
|
-
@instance = @klass.new(@env)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "executing" do
|
13
|
-
setup do
|
14
|
-
@instance.stubs(:show_single)
|
15
|
-
end
|
16
|
-
|
17
|
-
should "require root path" do
|
18
|
-
@env.expects(:require_root_path).once
|
19
|
-
@instance.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
should "call show_single with given argument" do
|
23
|
-
@instance.expects(:show_single).with("foo").once
|
24
|
-
@instance.execute(["foo"])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "showing a single entry" do
|
29
|
-
setup do
|
30
|
-
@ssh = mock("ssh")
|
31
|
-
@ssh.stubs(:port).returns(2197)
|
32
|
-
|
33
|
-
@bar = mock("vm")
|
34
|
-
@bar.stubs(:env).returns(mock_environment)
|
35
|
-
@bar.stubs(:ssh).returns(@ssh)
|
36
|
-
|
37
|
-
@vms = {:bar => @bar}
|
38
|
-
@env.stubs(:multivm?).returns(true)
|
39
|
-
@env.stubs(:vms).returns(@vms)
|
40
|
-
|
41
|
-
@data = {
|
42
|
-
:host_key => "vagrant",
|
43
|
-
:ssh_user => @bar.env.config.ssh.username,
|
44
|
-
:ssh_port => @bar.ssh.port,
|
45
|
-
:private_key_path => @bar.env.config.ssh.private_key_path
|
46
|
-
}
|
47
|
-
|
48
|
-
@instance.stubs(:puts)
|
49
|
-
end
|
50
|
-
|
51
|
-
should "error if name is nil and multivm" do
|
52
|
-
@env.stubs(:multivm?).returns(true)
|
53
|
-
@instance.expects(:error_and_exit).with(:ssh_config_multivm).once
|
54
|
-
@instance.show_single(nil)
|
55
|
-
end
|
56
|
-
|
57
|
-
should "error if the VM is not found" do
|
58
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => "foo").once
|
59
|
-
@instance.show_single("foo")
|
60
|
-
end
|
61
|
-
|
62
|
-
should "output rendered template" do
|
63
|
-
result = mock("result")
|
64
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)
|
65
|
-
|
66
|
-
@instance.expects(:puts).with(result).once
|
67
|
-
@instance.show_single(:bar)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "render with the given host name if given" do
|
71
|
-
host = "foo"
|
72
|
-
@data[:host_key] = host
|
73
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
|
74
|
-
@instance.execute(["bar", "--host", host])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsSSHTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::SSH
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "connect to the given argument" do
|
13
|
-
@instance.expects(:ssh_connect).with("foo").once
|
14
|
-
@instance.execute(["foo"])
|
15
|
-
end
|
16
|
-
|
17
|
-
should "connect with nil name if none is given" do
|
18
|
-
@instance.expects(:ssh_connect).with(nil).once
|
19
|
-
@instance.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
should "execute if commands are given" do
|
23
|
-
@env.stubs(:vms).returns(:foo => mock("foo"))
|
24
|
-
@instance.expects(:ssh_execute).with("foo", @env.vms[:foo]).once
|
25
|
-
@instance.execute(["foo","-e","bar"])
|
26
|
-
end
|
27
|
-
|
28
|
-
should "execute over every VM if none is specified with a command" do
|
29
|
-
vms = {
|
30
|
-
:foo => mock("foo"),
|
31
|
-
:bar => mock("bar")
|
32
|
-
}
|
33
|
-
|
34
|
-
@env.stubs(:vms).returns(vms)
|
35
|
-
vms.each do |key, vm|
|
36
|
-
@instance.expects(:ssh_execute).with(key, vm).once
|
37
|
-
end
|
38
|
-
|
39
|
-
@instance.execute(["--execute", "bar"])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "ssh executing" do
|
44
|
-
setup do
|
45
|
-
@name = :foo
|
46
|
-
|
47
|
-
@ssh_conn = mock("connection")
|
48
|
-
@ssh_conn.stubs(:exec!)
|
49
|
-
|
50
|
-
@ssh = mock("ssh")
|
51
|
-
@ssh.stubs(:execute).yields(@ssh_conn)
|
52
|
-
|
53
|
-
@vm = mock("vm")
|
54
|
-
@vm.stubs(:created?).returns(true)
|
55
|
-
@vm.stubs(:ssh).returns(@ssh)
|
56
|
-
@vm.stubs(:env).returns(@env)
|
57
|
-
end
|
58
|
-
|
59
|
-
should "error and exit if invalid VM given" do
|
60
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => @name).once
|
61
|
-
@instance.ssh_execute(@name, nil)
|
62
|
-
end
|
63
|
-
|
64
|
-
should "error and exit if VM isn't created" do
|
65
|
-
@vm.stubs(:created?).returns(false)
|
66
|
-
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
67
|
-
@instance.ssh_execute(@name, @vm)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "execute each command" do
|
71
|
-
commands = [:a,:b,:c]
|
72
|
-
@instance.stubs(:options).returns(:execute => commands)
|
73
|
-
commands.each do |cmd|
|
74
|
-
@ssh_conn.expects(:exec!).with(cmd).once
|
75
|
-
end
|
76
|
-
|
77
|
-
@instance.ssh_execute(@name, @vm)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "ssh connecting" do
|
82
|
-
setup do
|
83
|
-
@vm = mock("vm")
|
84
|
-
@vm.stubs(:created?).returns(true)
|
85
|
-
|
86
|
-
@vms = {:bar => @vm}
|
87
|
-
@env.stubs(:vms).returns(@vms)
|
88
|
-
@env.stubs(:multivm?).returns(false)
|
89
|
-
end
|
90
|
-
|
91
|
-
should "error and exit if no VM is specified and multivm and no primary VM" do
|
92
|
-
@env.stubs(:multivm?).returns(true)
|
93
|
-
@env.stubs(:primary_vm).returns(nil)
|
94
|
-
@instance.expects(:error_and_exit).with(:ssh_multivm).once
|
95
|
-
@instance.ssh_connect(nil)
|
96
|
-
end
|
97
|
-
|
98
|
-
should "use the primary VM if it exists and no name is specified" do
|
99
|
-
vm = mock("vm")
|
100
|
-
ssh = mock("ssh")
|
101
|
-
vm.stubs(:created?).returns(true)
|
102
|
-
vm.stubs(:ssh).returns(ssh)
|
103
|
-
|
104
|
-
@env.stubs(:multivm?).returns(true)
|
105
|
-
@env.stubs(:primary_vm).returns(vm)
|
106
|
-
ssh.expects(:connect).once
|
107
|
-
@instance.ssh_connect(nil)
|
108
|
-
end
|
109
|
-
|
110
|
-
should "error and exit if VM is nil" do
|
111
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
112
|
-
@instance.ssh_connect(:foo)
|
113
|
-
end
|
114
|
-
|
115
|
-
should "error and exit if VM isn't created" do
|
116
|
-
@vm.stubs(:created?).returns(false)
|
117
|
-
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
118
|
-
@instance.ssh_connect(:bar)
|
119
|
-
end
|
120
|
-
|
121
|
-
should "ssh connect" do
|
122
|
-
ssh = mock("ssh")
|
123
|
-
@vm.stubs(:ssh).returns(ssh)
|
124
|
-
ssh.expects(:connect)
|
125
|
-
|
126
|
-
@instance.ssh_connect(:bar)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsStatusTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Status
|
6
|
-
|
7
|
-
@persisted_vm = mock("persisted_vm")
|
8
|
-
@persisted_vm.stubs(:execute!)
|
9
|
-
|
10
|
-
@env = mock_environment
|
11
|
-
@env.stubs(:require_persisted_vm)
|
12
|
-
@env.stubs(:vm).returns(@persisted_vm)
|
13
|
-
|
14
|
-
@instance = @klass.new(@env)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "executing" do
|
18
|
-
should "show local status by default" do
|
19
|
-
@instance.expects(:show_local_status).once
|
20
|
-
@instance.expects(:show_global_status).never
|
21
|
-
@instance.execute
|
22
|
-
end
|
23
|
-
|
24
|
-
should "show global status if flagged" do
|
25
|
-
@instance.expects(:show_local_status).never
|
26
|
-
@instance.expects(:show_global_status).once
|
27
|
-
@instance.execute(["--global"])
|
28
|
-
end
|
29
|
-
|
30
|
-
should "show help if too many args are given" do
|
31
|
-
@instance.expects(:show_help).once
|
32
|
-
@instance.execute(["1","2","3"])
|
33
|
-
end
|
34
|
-
|
35
|
-
should "pass the VM name to local status if given" do
|
36
|
-
@instance.expects(:show_local_status).with("foo").once
|
37
|
-
@instance.execute(["foo"])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsSuspendTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Suspend
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "call all or single for the method" do
|
13
|
-
@instance.expects(:all_or_single).with([], :suspend)
|
14
|
-
@instance.execute
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "suspending a single VM" do
|
19
|
-
setup do
|
20
|
-
@foo_vm = mock("vm")
|
21
|
-
@foo_vm.stubs(:env).returns(@env)
|
22
|
-
vms = { :foo => @foo_vm }
|
23
|
-
@env.stubs(:vms).returns(vms)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "error and exit if the VM doesn't exist" do
|
27
|
-
@env.stubs(:vms).returns({})
|
28
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
-
@instance.suspend_single(:foo)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "suspend if its created" do
|
33
|
-
@foo_vm.stubs(:created?).returns(true)
|
34
|
-
@foo_vm.expects(:suspend).once
|
35
|
-
@instance.execute(["foo"])
|
36
|
-
end
|
37
|
-
|
38
|
-
should "do nothing if its not created" do
|
39
|
-
@foo_vm.stubs(:created?).returns(false)
|
40
|
-
@foo_vm.expects(:suspend).never
|
41
|
-
@instance.suspend_single(:foo)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CommandsUpTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Up
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@env.stubs(:require_root_path)
|
9
|
-
@instance = @klass.new(@env)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "executing" do
|
13
|
-
should "call all or single for the method" do
|
14
|
-
seq = sequence("seq")
|
15
|
-
@env.expects(:require_root_path).in_sequence(seq)
|
16
|
-
@instance.expects(:all_or_single).with([], :up).in_sequence(seq)
|
17
|
-
@instance.execute
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "upping a single VM" do
|
22
|
-
setup do
|
23
|
-
@vm = mock("vm")
|
24
|
-
@vm.stubs(:env).returns(@env)
|
25
|
-
|
26
|
-
@vms = {:foo => @vm}
|
27
|
-
@env.stubs(:vms).returns(@vms)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "error and exit if the VM doesn't exist" do
|
31
|
-
@env.stubs(:vms).returns({})
|
32
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
33
|
-
@instance.up_single(:foo)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "start created VMs" do
|
37
|
-
@vm.stubs(:created?).returns(true)
|
38
|
-
@vm.expects(:start).once
|
39
|
-
@instance.up_single(:foo)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "up non-created VMs" do
|
43
|
-
@vm.stubs(:created?).returns(false)
|
44
|
-
@vm.expects(:up).once
|
45
|
-
@vm.expects(:start).never
|
46
|
-
@instance.up_single(:foo)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TranslatorUtilTest < Test::Unit::TestCase
|
4
|
-
include Vagrant::Util
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@klass = Translator
|
8
|
-
end
|
9
|
-
|
10
|
-
context "loading the errors from the YML" do
|
11
|
-
setup do
|
12
|
-
YAML.stubs(:load_file)
|
13
|
-
@klass.reset!
|
14
|
-
end
|
15
|
-
|
16
|
-
should "load the file initially, then never again unless reset" do
|
17
|
-
YAML.expects(:load_file).with(File.join(PROJECT_ROOT, "templates", "strings.yml")).once
|
18
|
-
@klass.strings
|
19
|
-
@klass.strings
|
20
|
-
@klass.strings
|
21
|
-
@klass.strings
|
22
|
-
end
|
23
|
-
|
24
|
-
should "reload if reset! is called" do
|
25
|
-
YAML.expects(:load_file).with(File.join(PROJECT_ROOT, "templates", "strings.yml")).twice
|
26
|
-
@klass.strings
|
27
|
-
@klass.reset!
|
28
|
-
@klass.strings
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "getting the string translated" do
|
33
|
-
setup do
|
34
|
-
@strings = {}
|
35
|
-
@strings[:foo] = "foo bar baz"
|
36
|
-
@klass.stubs(:strings).returns(@strings)
|
37
|
-
end
|
38
|
-
|
39
|
-
should "render the error string" do
|
40
|
-
TemplateRenderer.expects(:render_string).with(@strings[:foo], anything).once
|
41
|
-
@klass.t(:foo)
|
42
|
-
end
|
43
|
-
|
44
|
-
should "pass in any data entries" do
|
45
|
-
data = mock("data")
|
46
|
-
TemplateRenderer.expects(:render_string).with(@strings[:foo], data).once
|
47
|
-
@klass.t(:foo, data)
|
48
|
-
end
|
49
|
-
|
50
|
-
should "return the result of the render" do
|
51
|
-
result = mock("result")
|
52
|
-
TemplateRenderer.expects(:render_string).returns(result)
|
53
|
-
assert_equal result, @klass.t(:foo)
|
54
|
-
end
|
55
|
-
|
56
|
-
should "return an unknown if the key doesn't exist" do
|
57
|
-
result = @klass.t(:unknown)
|
58
|
-
assert result =~ /Unknown/i
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|