vagrantup 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +17 -0
- data/README.md +45 -0
- data/Rakefile +41 -0
- data/VERSION +1 -0
- data/bin/.gitignore +0 -0
- data/bin/vagrant +15 -0
- data/bin/vagrant-box +35 -0
- data/bin/vagrant-down +28 -0
- data/bin/vagrant-halt +29 -0
- data/bin/vagrant-init +28 -0
- data/bin/vagrant-package +30 -0
- data/bin/vagrant-reload +30 -0
- data/bin/vagrant-resume +28 -0
- data/bin/vagrant-ssh +28 -0
- data/bin/vagrant-suspend +28 -0
- data/bin/vagrant-up +30 -0
- data/config/default.rb +29 -0
- data/lib/vagrant.rb +14 -0
- data/lib/vagrant/actions/base.rb +93 -0
- data/lib/vagrant/actions/box/add.rb +22 -0
- data/lib/vagrant/actions/box/destroy.rb +14 -0
- data/lib/vagrant/actions/box/download.rb +63 -0
- data/lib/vagrant/actions/box/unpackage.rb +49 -0
- data/lib/vagrant/actions/runner.rb +128 -0
- data/lib/vagrant/actions/vm/destroy.rb +14 -0
- data/lib/vagrant/actions/vm/down.rb +12 -0
- data/lib/vagrant/actions/vm/export.rb +41 -0
- data/lib/vagrant/actions/vm/forward_ports.rb +32 -0
- data/lib/vagrant/actions/vm/halt.rb +14 -0
- data/lib/vagrant/actions/vm/import.rb +17 -0
- data/lib/vagrant/actions/vm/move_hard_drive.rb +53 -0
- data/lib/vagrant/actions/vm/package.rb +61 -0
- data/lib/vagrant/actions/vm/provision.rb +71 -0
- data/lib/vagrant/actions/vm/reload.rb +17 -0
- data/lib/vagrant/actions/vm/resume.rb +16 -0
- data/lib/vagrant/actions/vm/shared_folders.rb +69 -0
- data/lib/vagrant/actions/vm/start.rb +50 -0
- data/lib/vagrant/actions/vm/suspend.rb +16 -0
- data/lib/vagrant/actions/vm/up.rb +35 -0
- data/lib/vagrant/box.rb +129 -0
- data/lib/vagrant/busy.rb +73 -0
- data/lib/vagrant/commands.rb +174 -0
- data/lib/vagrant/config.rb +156 -0
- data/lib/vagrant/downloaders/base.rb +13 -0
- data/lib/vagrant/downloaders/file.rb +21 -0
- data/lib/vagrant/downloaders/http.rb +47 -0
- data/lib/vagrant/env.rb +140 -0
- data/lib/vagrant/ssh.rb +43 -0
- data/lib/vagrant/util.rb +45 -0
- data/lib/vagrant/vm.rb +57 -0
- data/script/vagrant-ssh-expect.sh +22 -0
- data/templates/Vagrantfile +8 -0
- data/test/test_helper.rb +91 -0
- data/test/vagrant/actions/base_test.rb +32 -0
- data/test/vagrant/actions/box/add_test.rb +37 -0
- data/test/vagrant/actions/box/destroy_test.rb +18 -0
- data/test/vagrant/actions/box/download_test.rb +118 -0
- data/test/vagrant/actions/box/unpackage_test.rb +101 -0
- data/test/vagrant/actions/runner_test.rb +236 -0
- data/test/vagrant/actions/vm/destroy_test.rb +24 -0
- data/test/vagrant/actions/vm/down_test.rb +32 -0
- data/test/vagrant/actions/vm/export_test.rb +88 -0
- data/test/vagrant/actions/vm/forward_ports_test.rb +50 -0
- data/test/vagrant/actions/vm/halt_test.rb +27 -0
- data/test/vagrant/actions/vm/import_test.rb +36 -0
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +108 -0
- data/test/vagrant/actions/vm/package_test.rb +155 -0
- data/test/vagrant/actions/vm/provision_test.rb +103 -0
- data/test/vagrant/actions/vm/reload_test.rb +44 -0
- data/test/vagrant/actions/vm/resume_test.rb +27 -0
- data/test/vagrant/actions/vm/shared_folders_test.rb +117 -0
- data/test/vagrant/actions/vm/start_test.rb +55 -0
- data/test/vagrant/actions/vm/suspend_test.rb +27 -0
- data/test/vagrant/actions/vm/up_test.rb +76 -0
- data/test/vagrant/box_test.rb +92 -0
- data/test/vagrant/busy_test.rb +81 -0
- data/test/vagrant/commands_test.rb +252 -0
- data/test/vagrant/config_test.rb +123 -0
- data/test/vagrant/downloaders/base_test.rb +20 -0
- data/test/vagrant/downloaders/file_test.rb +32 -0
- data/test/vagrant/downloaders/http_test.rb +40 -0
- data/test/vagrant/env_test.rb +293 -0
- data/test/vagrant/ssh_test.rb +95 -0
- data/test/vagrant/util_test.rb +64 -0
- data/test/vagrant/vm_test.rb +96 -0
- metadata +263 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
class ProvisionActionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Provision)
|
6
|
+
|
7
|
+
Vagrant::SSH.stubs(:execute)
|
8
|
+
Vagrant::SSH.stubs(:upload!)
|
9
|
+
|
10
|
+
mock_config
|
11
|
+
end
|
12
|
+
|
13
|
+
context "shared folders" do
|
14
|
+
should "setup shared folder on VM for the cookbooks" do
|
15
|
+
File.expects(:expand_path).with(Vagrant.config.chef.cookbooks_path, Vagrant::Env.root_path).returns("foo")
|
16
|
+
@action.expects(:cookbooks_path).returns("bar")
|
17
|
+
assert_equal ["vagrant-provisioning", "foo", "bar"], @action.collect_shared_folders
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "cookbooks path" do
|
22
|
+
should "return the proper cookbook path" do
|
23
|
+
cookbooks_path = File.join(Vagrant.config.chef.provisioning_path, "cookbooks")
|
24
|
+
assert_equal cookbooks_path, @action.cookbooks_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "permissions on provisioning folder" do
|
29
|
+
should "chown the folder to the ssh user" do
|
30
|
+
ssh = mock("ssh")
|
31
|
+
ssh.expects(:exec!).with("sudo chown #{Vagrant.config.ssh.username} #{Vagrant.config.chef.provisioning_path}")
|
32
|
+
Vagrant::SSH.expects(:execute).yields(ssh)
|
33
|
+
@action.chown_provisioning_folder
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "generating and uploading json" do
|
38
|
+
def assert_json
|
39
|
+
Vagrant::SSH.expects(:upload!).with do |json, path|
|
40
|
+
data = JSON.parse(json.read)
|
41
|
+
yield data
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
@action.setup_json
|
46
|
+
end
|
47
|
+
|
48
|
+
should "merge in the extra json specified in the config" do
|
49
|
+
Vagrant.config.chef.json = { :foo => "BAR" }
|
50
|
+
assert_json do |data|
|
51
|
+
assert_equal "BAR", data["foo"]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
should "add the directory as a special case to the JSON" do
|
56
|
+
assert_json do |data|
|
57
|
+
assert_equal Vagrant.config.vm.project_directory, data["vagrant"]["directory"]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
should "add the config to the JSON" do
|
62
|
+
assert_json do |data|
|
63
|
+
assert_equal Vagrant.config.vm.project_directory, data["vagrant"]["config"]["vm"]["project_directory"]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
should "upload a StringIO to dna.json" do
|
68
|
+
StringIO.expects(:new).with(anything).returns("bar")
|
69
|
+
File.expects(:join).with(Vagrant.config.chef.provisioning_path, "dna.json").once.returns("baz")
|
70
|
+
Vagrant::SSH.expects(:upload!).with("bar", "baz").once
|
71
|
+
@action.setup_json
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "generating and uploading chef solo configuration file" do
|
76
|
+
should "upload properly generate the configuration file using configuration data" do
|
77
|
+
expected_config = <<-config
|
78
|
+
file_cache_path "#{Vagrant.config.chef.provisioning_path}"
|
79
|
+
cookbook_path "#{@action.cookbooks_path}"
|
80
|
+
config
|
81
|
+
|
82
|
+
StringIO.expects(:new).with(expected_config).once
|
83
|
+
@action.setup_solo_config
|
84
|
+
end
|
85
|
+
|
86
|
+
should "upload this file as solo.rb to the provisioning folder" do
|
87
|
+
@action.expects(:cookbooks_path).returns("cookbooks")
|
88
|
+
StringIO.expects(:new).returns("foo")
|
89
|
+
File.expects(:join).with(Vagrant.config.chef.provisioning_path, "solo.rb").once.returns("bar")
|
90
|
+
Vagrant::SSH.expects(:upload!).with("foo", "bar").once
|
91
|
+
@action.setup_solo_config
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "running chef solo" do
|
96
|
+
should "cd into the provisioning directory and run chef solo" do
|
97
|
+
ssh = mock("ssh")
|
98
|
+
ssh.expects(:exec!).with("cd #{Vagrant.config.chef.provisioning_path} && sudo chef-solo -c solo.rb -j dna.json").once
|
99
|
+
Vagrant::SSH.expects(:execute).yields(ssh)
|
100
|
+
@action.run_chef_solo
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
mock_config
|
7
|
+
end
|
8
|
+
|
9
|
+
context "sub-actions" do
|
10
|
+
setup do
|
11
|
+
@default_order = [Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
|
12
|
+
@vm.stubs(:running?).returns(false)
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup_action_expectations
|
16
|
+
default_seq = sequence("default_seq")
|
17
|
+
@default_order.each do |action|
|
18
|
+
@runner.expects(:add_action).with(action).once.in_sequence(default_seq)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
should "do the proper actions by default" do
|
23
|
+
setup_action_expectations
|
24
|
+
@action.prepare
|
25
|
+
end
|
26
|
+
|
27
|
+
should "halt if the VM is running" do
|
28
|
+
@vm.expects(:running?).returns(true)
|
29
|
+
@default_order.unshift(Vagrant::Actions::VM::Halt)
|
30
|
+
setup_action_expectations
|
31
|
+
@action.prepare
|
32
|
+
end
|
33
|
+
|
34
|
+
should "add in the provisioning step if enabled" do
|
35
|
+
mock_config do |config|
|
36
|
+
config.chef.enabled = true
|
37
|
+
end
|
38
|
+
|
39
|
+
@default_order.push(Vagrant::Actions::VM::Provision)
|
40
|
+
setup_action_expectations
|
41
|
+
@action.prepare
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
mock_config
|
7
|
+
end
|
8
|
+
|
9
|
+
context "executing" do
|
10
|
+
setup do
|
11
|
+
@vm.stubs(:saved?).returns(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "save the state of the VM" do
|
15
|
+
@runner.expects(:start).once
|
16
|
+
@action.execute!
|
17
|
+
end
|
18
|
+
|
19
|
+
should "raise an ActionException if the VM is not saved" do
|
20
|
+
@vm.expects(:saved?).returns(false)
|
21
|
+
@vm.expects(:start).never
|
22
|
+
assert_raises(Vagrant::Actions::ActionException) {
|
23
|
+
@action.execute!
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
class SharedFoldersActionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::SharedFolders)
|
6
|
+
mock_config
|
7
|
+
end
|
8
|
+
|
9
|
+
def stub_shared_folders
|
10
|
+
folders = [%w{foo from to}, %w{bar bfrom bto}]
|
11
|
+
@action.expects(:shared_folders).returns(folders)
|
12
|
+
folders
|
13
|
+
end
|
14
|
+
|
15
|
+
context "collecting shared folders" do
|
16
|
+
should "return the arrays that the callback returns" do
|
17
|
+
result = [[1,2,3],[4,5,6]]
|
18
|
+
@mock_vm.expects(:invoke_callback).with(:collect_shared_folders).once.returns(result)
|
19
|
+
assert_equal result, @action.shared_folders
|
20
|
+
end
|
21
|
+
|
22
|
+
should "filter out invalid results" do
|
23
|
+
result = [[1,2,3],[4,5]]
|
24
|
+
@mock_vm.expects(:invoke_callback).with(:collect_shared_folders).once.returns(result)
|
25
|
+
assert_equal [[1,2,3]], @action.shared_folders
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "setting up shared folder metadata" do
|
30
|
+
setup do
|
31
|
+
@folders = stub_shared_folders
|
32
|
+
end
|
33
|
+
|
34
|
+
should "add all shared folders to the VM" do
|
35
|
+
share_seq = sequence("share_seq")
|
36
|
+
shared_folders = mock("shared_folders")
|
37
|
+
shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "foo" && sf.hostpath == "from" }
|
38
|
+
shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "bar" && sf.hostpath == "bfrom" }
|
39
|
+
@vm.stubs(:shared_folders).returns(shared_folders)
|
40
|
+
@vm.expects(:save).with(true).once
|
41
|
+
|
42
|
+
@action.before_boot
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "mounting the shared folders" do
|
47
|
+
setup do
|
48
|
+
@folders = stub_shared_folders
|
49
|
+
end
|
50
|
+
|
51
|
+
should "mount all shared folders to the VM" do
|
52
|
+
mount_seq = sequence("mount_seq")
|
53
|
+
ssh = mock("ssh")
|
54
|
+
@folders.each do |name, hostpath, guestpath|
|
55
|
+
ssh.expects(:exec!).with("sudo mkdir -p #{guestpath}").in_sequence(mount_seq)
|
56
|
+
@action.expects(:mount_folder).with(ssh, name, guestpath).in_sequence(mount_seq)
|
57
|
+
ssh.expects(:exec!).with("sudo chown #{Vagrant.config.ssh.username} #{guestpath}").in_sequence(mount_seq)
|
58
|
+
end
|
59
|
+
Vagrant::SSH.expects(:execute).yields(ssh)
|
60
|
+
|
61
|
+
@action.after_boot
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "mounting the main folder" do
|
66
|
+
setup do
|
67
|
+
@ssh = mock("ssh")
|
68
|
+
@name = "foo"
|
69
|
+
@guestpath = "bar"
|
70
|
+
@sleeptime = 0
|
71
|
+
@limit = 10
|
72
|
+
|
73
|
+
@success_return = false
|
74
|
+
end
|
75
|
+
|
76
|
+
def mount_folder
|
77
|
+
@action.mount_folder(@ssh, @name, @guestpath, @sleeptime)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "execute the proper mount command" do
|
81
|
+
@ssh.expects(:exec!).with("sudo mount -t vboxsf #{@name} #{@guestpath}").returns(@success_return)
|
82
|
+
mount_folder
|
83
|
+
end
|
84
|
+
|
85
|
+
should "test type of text and text string to detect error" do
|
86
|
+
data = mock("data")
|
87
|
+
data.expects(:[]=).with(:result, !@success_return)
|
88
|
+
|
89
|
+
@ssh.expects(:exec!).yields(data, :stderr, "No such device").returns(@success_return)
|
90
|
+
mount_folder
|
91
|
+
end
|
92
|
+
|
93
|
+
should "test type of text and test string to detect success" do
|
94
|
+
data = mock("data")
|
95
|
+
data.expects(:[]=).with(:result, @success_return)
|
96
|
+
|
97
|
+
@ssh.expects(:exec!).yields(data, :stdout, "Nothing such device").returns(@success_return)
|
98
|
+
mount_folder
|
99
|
+
end
|
100
|
+
|
101
|
+
should "raise an ActionException if the command fails constantly" do
|
102
|
+
@ssh.expects(:exec!).times(@limit).returns(!@success_return)
|
103
|
+
|
104
|
+
assert_raises(Vagrant::Actions::ActionException) {
|
105
|
+
mount_folder
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
should "not raise any exception if the command succeeded" do
|
110
|
+
@ssh.expects(:exec!).once.returns(@success_return)
|
111
|
+
|
112
|
+
assert_nothing_raised {
|
113
|
+
mount_folder
|
114
|
+
}
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
class StartActionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
|
6
|
+
@mock_vm.stubs(:invoke_callback)
|
7
|
+
mock_config
|
8
|
+
end
|
9
|
+
|
10
|
+
context "execution" do
|
11
|
+
should "invoke the 'boot' around callback" do
|
12
|
+
boot_seq = sequence("boot_seq")
|
13
|
+
@mock_vm.expects(:invoke_around_callback).with(:boot).once.in_sequence(boot_seq).yields
|
14
|
+
@action.expects(:boot).in_sequence(boot_seq)
|
15
|
+
@action.expects(:wait_for_boot).returns(true).in_sequence(boot_seq)
|
16
|
+
@action.execute!
|
17
|
+
end
|
18
|
+
|
19
|
+
should "error and exit if the bootup failed" do
|
20
|
+
fail_boot_seq = sequence("fail_boot_seq")
|
21
|
+
@action.expects(:boot).once.in_sequence(fail_boot_seq)
|
22
|
+
@action.expects(:wait_for_boot).returns(false).in_sequence(fail_boot_seq)
|
23
|
+
@action.expects(:error_and_exit).once.in_sequence(fail_boot_seq)
|
24
|
+
@action.execute!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "booting" do
|
29
|
+
should "start the VM in headless mode" do
|
30
|
+
@vm.expects(:start).with(:headless, true).once
|
31
|
+
@action.boot
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "waiting for boot" do
|
36
|
+
should "repeatedly ping the SSH port and return false with no response" do
|
37
|
+
seq = sequence('pings')
|
38
|
+
Vagrant::SSH.expects(:up?).times(Vagrant.config[:ssh][:max_tries].to_i - 1).returns(false).in_sequence(seq)
|
39
|
+
Vagrant::SSH.expects(:up?).once.returns(true).in_sequence(seq)
|
40
|
+
assert @action.wait_for_boot(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "ping the max number of times then just return" do
|
44
|
+
Vagrant::SSH.expects(:up?).times(Vagrant.config[:ssh][:max_tries].to_i).returns(false)
|
45
|
+
assert !@action.wait_for_boot(0)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "callbacks" do
|
50
|
+
should "setup the root directory shared folder" do
|
51
|
+
expected = ["vagrant-root", Vagrant::Env.root_path, Vagrant.config.vm.project_directory]
|
52
|
+
assert_equal expected, @action.collect_shared_folders
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
class SuspendActionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Suspend)
|
6
|
+
mock_config
|
7
|
+
end
|
8
|
+
|
9
|
+
context "executing" do
|
10
|
+
setup do
|
11
|
+
@vm.stubs(:running?).returns(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "save the state of the VM" do
|
15
|
+
@vm.expects(:save_state).with(true).once
|
16
|
+
@action.execute!
|
17
|
+
end
|
18
|
+
|
19
|
+
should "raise an ActionException if the VM is not running" do
|
20
|
+
@vm.expects(:running?).returns(false)
|
21
|
+
@vm.expects(:save_state).never
|
22
|
+
assert_raises(Vagrant::Actions::ActionException) {
|
23
|
+
@action.execute!
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
class UpActionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Up)
|
6
|
+
mock_config
|
7
|
+
end
|
8
|
+
|
9
|
+
context "sub-actions" do
|
10
|
+
setup do
|
11
|
+
@default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup_action_expectations
|
15
|
+
default_seq = sequence("default_seq")
|
16
|
+
@default_order.each do |action|
|
17
|
+
@mock_vm.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 "add in the provisioning step if enabled" do
|
27
|
+
mock_config do |config|
|
28
|
+
config.chef.enabled = true
|
29
|
+
end
|
30
|
+
|
31
|
+
@default_order.push(Vagrant::Actions::VM::Provision)
|
32
|
+
setup_action_expectations
|
33
|
+
@action.prepare
|
34
|
+
end
|
35
|
+
|
36
|
+
should "add in the action to move hard drive if config is set" do
|
37
|
+
mock_config do |config|
|
38
|
+
File.expects(:directory?).with("foo").returns(true)
|
39
|
+
config.vm.hd_location = "foo"
|
40
|
+
end
|
41
|
+
|
42
|
+
@default_order.insert(0, Vagrant::Actions::VM::MoveHardDrive)
|
43
|
+
setup_action_expectations
|
44
|
+
@action.prepare
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "callbacks" do
|
49
|
+
should "call persist and mac address setup after import" do
|
50
|
+
boot_seq = sequence("boot")
|
51
|
+
@action.expects(:persist).once.in_sequence(boot_seq)
|
52
|
+
@action.expects(:setup_mac_address).once.in_sequence(boot_seq)
|
53
|
+
@action.after_import
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "persisting" do
|
58
|
+
should "persist the VM with Env" do
|
59
|
+
@vm.stubs(:uuid)
|
60
|
+
Vagrant::Env.expects(:persist_vm).with(@vm).once
|
61
|
+
@action.persist
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "setting up MAC address" do
|
66
|
+
should "match the mac address with the base" do
|
67
|
+
nic = mock("nic")
|
68
|
+
nic.expects(:macaddress=).once
|
69
|
+
|
70
|
+
@vm.expects(:nics).returns([nic]).once
|
71
|
+
@vm.expects(:save).with(true).once
|
72
|
+
|
73
|
+
@action.setup_mac_address
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|