vagrant 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/config/default.rb +6 -6
- data/lib/vagrant.rb +6 -3
- data/lib/vagrant/action.rb +77 -0
- data/lib/vagrant/action/action_exception.rb +16 -0
- data/lib/vagrant/action/box/destroy.rb +19 -0
- data/lib/vagrant/action/box/download.rb +78 -0
- data/lib/vagrant/action/box/unpackage.rb +58 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +151 -0
- data/lib/vagrant/action/builtin.rb +114 -0
- data/lib/vagrant/action/env/error_halt.rb +16 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +98 -0
- data/lib/vagrant/action/exception_catcher.rb +14 -0
- data/lib/vagrant/action/vm/boot.rb +54 -0
- data/lib/vagrant/action/vm/check_box.rb +27 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +32 -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 +20 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
- data/lib/vagrant/action/vm/disable_networks.rb +26 -0
- data/lib/vagrant/action/vm/export.rb +53 -0
- data/lib/vagrant/action/vm/forward_ports.rb +121 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +34 -0
- data/lib/vagrant/action/vm/import.rb +33 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
- data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
- data/lib/vagrant/action/vm/nfs.rb +161 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +99 -0
- data/lib/vagrant/action/vm/persist.rb +22 -0
- data/lib/vagrant/action/vm/provision.rb +50 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/box.rb +3 -7
- data/lib/vagrant/commands/base.rb +1 -3
- data/lib/vagrant/commands/package.rb +4 -9
- data/lib/vagrant/commands/up.rb +0 -2
- data/lib/vagrant/config.rb +15 -1
- data/lib/vagrant/downloaders/file.rb +1 -1
- data/lib/vagrant/downloaders/http.rb +2 -1
- data/lib/vagrant/environment.rb +18 -14
- data/lib/vagrant/hosts/base.rb +77 -0
- data/lib/vagrant/hosts/bsd.rb +53 -0
- data/lib/vagrant/hosts/linux.rb +52 -0
- data/lib/vagrant/provisioners/base.rb +17 -9
- data/lib/vagrant/provisioners/chef.rb +1 -1
- data/lib/vagrant/provisioners/chef_server.rb +4 -8
- data/lib/vagrant/provisioners/chef_solo.rb +1 -2
- data/lib/vagrant/ssh.rb +12 -4
- data/lib/vagrant/systems/base.rb +4 -0
- data/lib/vagrant/systems/linux.rb +12 -1
- data/lib/vagrant/util.rb +16 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/plain_logger.rb +11 -0
- data/lib/vagrant/util/platform.rb +18 -0
- data/lib/vagrant/util/resource_logger.rb +128 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +10 -12
- data/templates/chef_solo_solo.erb +2 -1
- data/templates/nfs/exports.erb +3 -0
- data/templates/nfs/exports_linux.erb +3 -0
- data/templates/strings.yml +23 -3
- metadata +128 -198
- data/.gitignore +0 -11
- data/Gemfile +0 -18
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/bin/.gitignore +0 -0
- data/lib/vagrant/actions/base.rb +0 -130
- data/lib/vagrant/actions/box/add.rb +0 -23
- data/lib/vagrant/actions/box/destroy.rb +0 -14
- data/lib/vagrant/actions/box/download.rb +0 -67
- data/lib/vagrant/actions/box/unpackage.rb +0 -42
- data/lib/vagrant/actions/box/verify.rb +0 -32
- data/lib/vagrant/actions/collection.rb +0 -36
- data/lib/vagrant/actions/runner.rb +0 -131
- data/lib/vagrant/actions/vm/boot.rb +0 -43
- data/lib/vagrant/actions/vm/customize.rb +0 -19
- data/lib/vagrant/actions/vm/destroy.rb +0 -24
- data/lib/vagrant/actions/vm/down.rb +0 -22
- data/lib/vagrant/actions/vm/export.rb +0 -45
- data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
- data/lib/vagrant/actions/vm/halt.rb +0 -24
- data/lib/vagrant/actions/vm/import.rb +0 -23
- data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
- data/lib/vagrant/actions/vm/package.rb +0 -94
- data/lib/vagrant/actions/vm/provision.rb +0 -49
- data/lib/vagrant/actions/vm/reload.rb +0 -17
- data/lib/vagrant/actions/vm/resume.rb +0 -16
- data/lib/vagrant/actions/vm/start.rb +0 -26
- data/lib/vagrant/actions/vm/suspend.rb +0 -16
- data/lib/vagrant/actions/vm/up.rb +0 -53
- data/lib/vagrant/busy.rb +0 -79
- data/lib/vagrant/resource_logger.rb +0 -126
- data/lib/vagrant/util/error_helper.rb +0 -13
- data/lib/vagrant/util/output_helper.rb +0 -9
- data/test/test_helper.rb +0 -149
- data/test/vagrant/actions/base_test.rb +0 -32
- data/test/vagrant/actions/box/add_test.rb +0 -36
- data/test/vagrant/actions/box/destroy_test.rb +0 -17
- data/test/vagrant/actions/box/download_test.rb +0 -137
- data/test/vagrant/actions/box/unpackage_test.rb +0 -99
- data/test/vagrant/actions/box/verify_test.rb +0 -44
- data/test/vagrant/actions/collection_test.rb +0 -113
- data/test/vagrant/actions/runner_test.rb +0 -268
- data/test/vagrant/actions/vm/boot_test.rb +0 -49
- data/test/vagrant/actions/vm/customize_test.rb +0 -21
- data/test/vagrant/actions/vm/destroy_test.rb +0 -37
- data/test/vagrant/actions/vm/down_test.rb +0 -39
- data/test/vagrant/actions/vm/export_test.rb +0 -88
- data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
- data/test/vagrant/actions/vm/halt_test.rb +0 -65
- data/test/vagrant/actions/vm/import_test.rb +0 -45
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
- data/test/vagrant/actions/vm/network_test.rb +0 -291
- data/test/vagrant/actions/vm/package_test.rb +0 -254
- data/test/vagrant/actions/vm/provision_test.rb +0 -99
- data/test/vagrant/actions/vm/reload_test.rb +0 -46
- data/test/vagrant/actions/vm/resume_test.rb +0 -26
- data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
- data/test/vagrant/actions/vm/start_test.rb +0 -73
- data/test/vagrant/actions/vm/suspend_test.rb +0 -26
- data/test/vagrant/actions/vm/up_test.rb +0 -96
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/box_test.rb +0 -154
- data/test/vagrant/busy_test.rb +0 -78
- 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/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -55
- data/test/vagrant/commands/package_test.rb +0 -104
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -44
- 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 -47
- data/test/vagrant/config_test.rb +0 -287
- data/test/vagrant/downloaders/base_test.rb +0 -28
- data/test/vagrant/downloaders/file_test.rb +0 -33
- data/test/vagrant/downloaders/http_test.rb +0 -62
- data/test/vagrant/environment_test.rb +0 -770
- data/test/vagrant/provisioners/base_test.rb +0 -33
- data/test/vagrant/provisioners/chef_server_test.rb +0 -176
- data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
- data/test/vagrant/provisioners/chef_test.rb +0 -175
- data/test/vagrant/resource_logger_test.rb +0 -145
- data/test/vagrant/ssh_session_test.rb +0 -46
- data/test/vagrant/ssh_test.rb +0 -296
- data/test/vagrant/systems/linux_test.rb +0 -179
- data/test/vagrant/util/error_helper_test.rb +0 -5
- data/test/vagrant/util/output_helper_test.rb +0 -5
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/platform_test.rb +0 -18
- data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/vagrant/util/template_renderer_test.rb +0 -144
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
- data/test/vagrant/vm_test.rb +0 -235
- data/vagrant.gemspec +0 -291
@@ -1,99 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class ProvisionActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Provision)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "initialization" do
|
9
|
-
should "have a nil provisioner by default" do
|
10
|
-
assert_nil @action.provisioner
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "executing" do
|
15
|
-
should "do nothing if the provisioner is nil" do
|
16
|
-
@action.expects(:provisioner).returns(nil)
|
17
|
-
assert_nothing_raised { @action.execute! }
|
18
|
-
end
|
19
|
-
|
20
|
-
should "call `provision!` on the provisioner" do
|
21
|
-
provisioner = mock("provisioner")
|
22
|
-
provisioner.expects(:provision!).once
|
23
|
-
@action.expects(:provisioner).twice.returns(provisioner)
|
24
|
-
@action.execute!
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "preparing" do
|
29
|
-
context "with a nil provisioner" do
|
30
|
-
setup do
|
31
|
-
@runner.env.config.vm.provisioner = nil
|
32
|
-
end
|
33
|
-
|
34
|
-
should "not set a provisioner if set to nil" do
|
35
|
-
@action.prepare
|
36
|
-
assert_nil @action.provisioner
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with a Class provisioner" do
|
41
|
-
setup do
|
42
|
-
@instance = mock("instance")
|
43
|
-
@instance.stubs(:is_a?).with(Vagrant::Provisioners::Base).returns(true)
|
44
|
-
@instance.stubs(:prepare)
|
45
|
-
@klass = mock("klass")
|
46
|
-
@klass.stubs(:is_a?).with(Class).returns(true)
|
47
|
-
@klass.stubs(:new).with(@runner).returns(@instance)
|
48
|
-
|
49
|
-
@runner.env.config.vm.provisioner = @klass
|
50
|
-
end
|
51
|
-
|
52
|
-
should "set the provisioner to an instantiation of the class" do
|
53
|
-
@klass.expects(:new).with(@runner).once.returns(@instance)
|
54
|
-
assert_nothing_raised { @action.prepare }
|
55
|
-
assert_equal @instance, @action.provisioner
|
56
|
-
end
|
57
|
-
|
58
|
-
should "call prepare on the instance" do
|
59
|
-
@instance.expects(:prepare).once
|
60
|
-
@action.prepare
|
61
|
-
end
|
62
|
-
|
63
|
-
should "raise an exception if the class is not a subclass of the provisioner base" do
|
64
|
-
@instance.expects(:is_a?).with(Vagrant::Provisioners::Base).returns(false)
|
65
|
-
assert_raises(Vagrant::Actions::ActionException) {
|
66
|
-
@action.prepare
|
67
|
-
}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "with a Symbol provisioner" do
|
72
|
-
def provisioner_expectation(symbol, provisioner)
|
73
|
-
@runner.env.config.vm.provisioner = symbol
|
74
|
-
|
75
|
-
instance = mock("instance")
|
76
|
-
instance.expects(:prepare).once
|
77
|
-
provisioner.expects(:new).with(@runner).returns(instance)
|
78
|
-
assert_nothing_raised { @action.prepare }
|
79
|
-
assert_equal instance, @action.provisioner
|
80
|
-
end
|
81
|
-
|
82
|
-
should "raise an ActionException if its an unknown symbol" do
|
83
|
-
@runner.env.config.vm.provisioner = :this_will_never_exist
|
84
|
-
|
85
|
-
assert_raises(Vagrant::Actions::ActionException) {
|
86
|
-
@action.prepare
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
should "set :chef_solo to the ChefSolo provisioner" do
|
91
|
-
provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo)
|
92
|
-
end
|
93
|
-
|
94
|
-
should "set :chef_server to the ChefServer provisioner" do
|
95
|
-
provisioner_expectation(:chef_server, Vagrant::Provisioners::ChefServer)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class ReloadActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Reload)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "sub-actions" do
|
9
|
-
setup do
|
10
|
-
@default_order = [Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Network, Vagrant::Actions::VM::Boot]
|
11
|
-
@vm.stubs(:running?).returns(false)
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup_action_expectations
|
15
|
-
default_seq = sequence("default_seq")
|
16
|
-
@default_order.each do |action|
|
17
|
-
@runner.expects(:add_action).with(action).once.in_sequence(default_seq)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
should "do the proper actions by default" do
|
22
|
-
setup_action_expectations
|
23
|
-
@action.prepare
|
24
|
-
end
|
25
|
-
|
26
|
-
should "halt if the VM is running" do
|
27
|
-
@vm.expects(:running?).returns(true)
|
28
|
-
@default_order.unshift(Vagrant::Actions::VM::Halt)
|
29
|
-
setup_action_expectations
|
30
|
-
@action.prepare
|
31
|
-
end
|
32
|
-
|
33
|
-
should "add in the provisioning step if enabled" do
|
34
|
-
env = mock_environment do |config|
|
35
|
-
# Dummy provisioner to test
|
36
|
-
config.vm.provisioner = "foo"
|
37
|
-
end
|
38
|
-
|
39
|
-
@runner.stubs(:env).returns(env)
|
40
|
-
|
41
|
-
@default_order.push(Vagrant::Actions::VM::Provision)
|
42
|
-
setup_action_expectations
|
43
|
-
@action.prepare
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class ResumeActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Resume)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "executing" do
|
9
|
-
setup do
|
10
|
-
@vm.stubs(:saved?).returns(true)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "save the state of the VM" do
|
14
|
-
@runner.expects(:start).once
|
15
|
-
@action.execute!
|
16
|
-
end
|
17
|
-
|
18
|
-
should "raise an ActionException if the VM is not saved" do
|
19
|
-
@vm.expects(:saved?).returns(false)
|
20
|
-
@vm.expects(:start).never
|
21
|
-
assert_raises(Vagrant::Actions::ActionException) {
|
22
|
-
@action.execute!
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class SharedFoldersActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::SharedFolders)
|
6
|
-
@runner.stubs(:system).returns(linux_system(@vm))
|
7
|
-
end
|
8
|
-
|
9
|
-
def stub_shared_folders
|
10
|
-
env = mock_environment do |config|
|
11
|
-
config.vm.shared_folders.clear
|
12
|
-
|
13
|
-
if block_given?
|
14
|
-
yield config
|
15
|
-
else
|
16
|
-
folders = [%w{foo fooguest foohost}, %w{bar barguest barhost}]
|
17
|
-
folders.each do |data|
|
18
|
-
config.vm.share_folder(*data)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
@runner.stubs(:env).returns(env)
|
24
|
-
env.config.vm.shared_folders
|
25
|
-
end
|
26
|
-
|
27
|
-
context "before boot" do
|
28
|
-
should "clear folders and create metadata, in order" do
|
29
|
-
before_seq = sequence("before")
|
30
|
-
@action.expects(:clear_shared_folders).once.in_sequence(before_seq)
|
31
|
-
@action.expects(:create_metadata).once.in_sequence(before_seq)
|
32
|
-
@action.before_boot
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "after boot" do
|
37
|
-
should "mount folders then setup unison" do
|
38
|
-
seq = sequence("after")
|
39
|
-
@action.expects(:mount_shared_folders).once.in_sequence(seq)
|
40
|
-
@action.expects(:setup_unison).once.in_sequence(seq)
|
41
|
-
@action.after_boot
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "collecting shared folders" do
|
46
|
-
setup do
|
47
|
-
File.stubs(:expand_path).returns("baz")
|
48
|
-
end
|
49
|
-
|
50
|
-
should "return a hash of the shared folders" do
|
51
|
-
data = {
|
52
|
-
"foo" => %W[bar baz],
|
53
|
-
"bar" => %W[foo baz]
|
54
|
-
}
|
55
|
-
|
56
|
-
stub_shared_folders do |config|
|
57
|
-
data.each do |name, value|
|
58
|
-
config.vm.share_folder(name, *value)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
result = @action.shared_folders
|
63
|
-
assert_equal data.length, result.length
|
64
|
-
data.each do |name, value|
|
65
|
-
guest, host = value
|
66
|
-
assert_equal guest, result[name][:guestpath]
|
67
|
-
assert_equal host, result[name][:hostpath]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
should "append sync suffix if sync enabled to a folder" do
|
72
|
-
name = "foo"
|
73
|
-
guest = "bar"
|
74
|
-
host = "baz"
|
75
|
-
|
76
|
-
stub_shared_folders do |config|
|
77
|
-
config.vm.share_folder(name, guest, host, :sync => true)
|
78
|
-
end
|
79
|
-
|
80
|
-
result = @action.shared_folders
|
81
|
-
assert_equal "#{guest}#{@runner.env.config.unison.folder_suffix}", result[name][:guestpath]
|
82
|
-
assert_equal guest, result[name][:original][:guestpath]
|
83
|
-
end
|
84
|
-
|
85
|
-
should "not destroy original hash" do
|
86
|
-
@folders = stub_shared_folders do |config|
|
87
|
-
config.vm.share_folder("foo", "bar", "baz", :sync => true)
|
88
|
-
end
|
89
|
-
|
90
|
-
folder = @folders["foo"].dup
|
91
|
-
|
92
|
-
@action.shared_folders
|
93
|
-
assert_equal folder, @runner.env.config.vm.shared_folders["foo"]
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "unison shared folders" do
|
98
|
-
setup do
|
99
|
-
@folders = stub_shared_folders do |config|
|
100
|
-
config.vm.share_folder("foo", "bar", "baz", :sync => true)
|
101
|
-
config.vm.share_folder("bar", "foo", "baz")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
should "only return the folders marked for syncing" do
|
106
|
-
result = @action.unison_folders
|
107
|
-
assert_equal 1, result.length
|
108
|
-
assert result.has_key?("foo")
|
109
|
-
assert !result.has_key?("bar")
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "clearing shared folders" do
|
114
|
-
setup do
|
115
|
-
@shared_folder = mock("shared_folder")
|
116
|
-
@shared_folders = [@shared_folder]
|
117
|
-
@vm.stubs(:shared_folders).returns(@shared_folders)
|
118
|
-
end
|
119
|
-
|
120
|
-
should "call destroy on each shared folder then reload" do
|
121
|
-
destroy_seq = sequence("destroy")
|
122
|
-
@shared_folders.each do |sf|
|
123
|
-
sf.expects(:destroy).once.in_sequence(destroy_seq)
|
124
|
-
end
|
125
|
-
|
126
|
-
@runner.expects(:reload!).once.in_sequence(destroy_seq)
|
127
|
-
@action.clear_shared_folders
|
128
|
-
end
|
129
|
-
|
130
|
-
should "do nothing if no shared folders existed" do
|
131
|
-
@shared_folders.clear
|
132
|
-
@runner.expects(:reload!).never
|
133
|
-
@action.clear_shared_folders
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "setting up shared folder metadata" do
|
138
|
-
setup do
|
139
|
-
stub_shared_folders
|
140
|
-
end
|
141
|
-
|
142
|
-
should "add all shared folders to the VM" do
|
143
|
-
shared_folders = []
|
144
|
-
data = %W[foo bar]
|
145
|
-
shared_folders.expects(:<<).times(data.length).with() do |sf|
|
146
|
-
hostpath = File.expand_path("#{sf.name}host", @runner.env.root_path)
|
147
|
-
assert data.include?(sf.name)
|
148
|
-
assert_equal hostpath, sf.host_path
|
149
|
-
true
|
150
|
-
end
|
151
|
-
|
152
|
-
@vm.stubs(:shared_folders).returns(shared_folders)
|
153
|
-
@vm.expects(:save).once
|
154
|
-
|
155
|
-
@action.create_metadata
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context "mounting the shared folders" do
|
160
|
-
setup do
|
161
|
-
@folders = stub_shared_folders
|
162
|
-
@ssh = mock("ssh")
|
163
|
-
@runner.ssh.stubs(:execute).yields(@ssh)
|
164
|
-
@runner.system.stubs(:mount_shared_folder)
|
165
|
-
end
|
166
|
-
|
167
|
-
should "mount all shared folders to the VM" do
|
168
|
-
mount_seq = sequence("mount_seq")
|
169
|
-
@folders.each do |name, data|
|
170
|
-
@runner.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq)
|
171
|
-
end
|
172
|
-
|
173
|
-
@action.mount_shared_folders
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context "setting up unison" do
|
178
|
-
setup do
|
179
|
-
@ssh = mock("ssh")
|
180
|
-
@runner.ssh.stubs(:execute).yields(@ssh)
|
181
|
-
|
182
|
-
@folders = stub_shared_folders do |config|
|
183
|
-
config.vm.share_folder("foo", "bar", "baz", :sync => true)
|
184
|
-
config.vm.share_folder("bar", "foo", "baz")
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
should "do nothing if unison folders is empty" do
|
189
|
-
@action.stubs(:unison_folders).returns({})
|
190
|
-
@runner.ssh.expects(:execute).never
|
191
|
-
@action.setup_unison
|
192
|
-
end
|
193
|
-
|
194
|
-
should "prepare unison then create for each folder" do
|
195
|
-
seq = sequence("unison seq")
|
196
|
-
@runner.system.expects(:prepare_unison).with(@ssh).once.in_sequence(seq)
|
197
|
-
@action.unison_folders.each do |name, data|
|
198
|
-
if data[:sync]
|
199
|
-
@runner.system.expects(:create_unison).with do |ssh, opts|
|
200
|
-
assert_equal @ssh, ssh
|
201
|
-
assert_equal data, opts
|
202
|
-
|
203
|
-
true
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
@action.setup_unison
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class StartActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
|
6
|
-
|
7
|
-
@action.options[:provision] = true
|
8
|
-
end
|
9
|
-
|
10
|
-
context "sub-actions" do
|
11
|
-
setup do
|
12
|
-
@runner.stubs(:created?).returns(false)
|
13
|
-
@vm.stubs(:saved?).returns(true)
|
14
|
-
File.stubs(:file?).returns(true)
|
15
|
-
File.stubs(:exist?).returns(true)
|
16
|
-
@default_order = [Vagrant::Actions::VM::Boot]
|
17
|
-
end
|
18
|
-
|
19
|
-
def setup_action_expectations
|
20
|
-
default_seq = sequence("default_seq")
|
21
|
-
@default_order.flatten.each do |action|
|
22
|
-
@runner.expects(:add_action).with(action, @action.options).once.in_sequence(default_seq)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
should "do the proper actions by default" do
|
27
|
-
setup_action_expectations
|
28
|
-
@action.prepare
|
29
|
-
end
|
30
|
-
|
31
|
-
should "add customize to the beginning if its not saved" do
|
32
|
-
@vm.expects(:saved?).returns(false)
|
33
|
-
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Network])
|
34
|
-
setup_action_expectations
|
35
|
-
@action.prepare
|
36
|
-
end
|
37
|
-
|
38
|
-
should "add do additional if VM is not created yet" do
|
39
|
-
@runner.stubs(:vm).returns(nil)
|
40
|
-
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Network])
|
41
|
-
setup_action_expectations
|
42
|
-
@action.prepare
|
43
|
-
end
|
44
|
-
|
45
|
-
should "add provisioning if its enabled and not saved" do
|
46
|
-
@vm.env.config.vm.provisioner = :chef_solo
|
47
|
-
|
48
|
-
@runner.stubs(:vm).returns(nil)
|
49
|
-
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Network])
|
50
|
-
@default_order << Vagrant::Actions::VM::Provision
|
51
|
-
setup_action_expectations
|
52
|
-
@action.prepare
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "provision?" do
|
57
|
-
should "return false if no provisioner is set" do
|
58
|
-
@vm.env.config.vm.provisioner = nil
|
59
|
-
assert !@action.provision?
|
60
|
-
end
|
61
|
-
|
62
|
-
should "return true if a provisioner is set" do
|
63
|
-
@vm.env.config.vm.provisioner = :chef_solo
|
64
|
-
assert @action.provision?
|
65
|
-
end
|
66
|
-
|
67
|
-
should "return false if provisioning is specifically disabled" do
|
68
|
-
@vm.env.config.vm.provisioner = :chef_solo
|
69
|
-
@action.options[:provision] = false
|
70
|
-
assert !@action.provision?
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|