vagrantup 0.4.3.dev → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/config/default.rb +6 -6
  4. data/lib/vagrant.rb +6 -3
  5. data/lib/vagrant/action.rb +77 -0
  6. data/lib/vagrant/action/action_exception.rb +16 -0
  7. data/lib/vagrant/action/box/destroy.rb +19 -0
  8. data/lib/vagrant/action/box/download.rb +78 -0
  9. data/lib/vagrant/action/box/unpackage.rb +58 -0
  10. data/lib/vagrant/action/box/verify.rb +23 -0
  11. data/lib/vagrant/action/builder.rb +151 -0
  12. data/lib/vagrant/action/builtin.rb +114 -0
  13. data/lib/vagrant/action/env/error_halt.rb +16 -0
  14. data/lib/vagrant/action/env/set.rb +18 -0
  15. data/lib/vagrant/action/environment.rb +98 -0
  16. data/lib/vagrant/action/exception_catcher.rb +14 -0
  17. data/lib/vagrant/action/vm/boot.rb +54 -0
  18. data/lib/vagrant/action/vm/check_box.rb +27 -0
  19. data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
  20. data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
  21. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
  22. data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
  23. data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
  24. data/lib/vagrant/action/vm/customize.rb +21 -0
  25. data/lib/vagrant/action/vm/destroy.rb +20 -0
  26. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
  27. data/lib/vagrant/action/vm/disable_networks.rb +26 -0
  28. data/lib/vagrant/action/vm/export.rb +53 -0
  29. data/lib/vagrant/action/vm/forward_ports.rb +121 -0
  30. data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
  31. data/lib/vagrant/action/vm/halt.rb +34 -0
  32. data/lib/vagrant/action/vm/import.rb +33 -0
  33. data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
  34. data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
  35. data/lib/vagrant/action/vm/nfs.rb +161 -0
  36. data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
  37. data/lib/vagrant/action/vm/package.rb +99 -0
  38. data/lib/vagrant/action/vm/persist.rb +22 -0
  39. data/lib/vagrant/action/vm/provision.rb +50 -0
  40. data/lib/vagrant/action/vm/resume.rb +20 -0
  41. data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
  42. data/lib/vagrant/action/vm/suspend.rb +20 -0
  43. data/lib/vagrant/box.rb +3 -7
  44. data/lib/vagrant/commands/base.rb +1 -3
  45. data/lib/vagrant/commands/package.rb +4 -9
  46. data/lib/vagrant/commands/up.rb +0 -2
  47. data/lib/vagrant/config.rb +15 -1
  48. data/lib/vagrant/downloaders/file.rb +1 -1
  49. data/lib/vagrant/downloaders/http.rb +2 -1
  50. data/lib/vagrant/environment.rb +18 -14
  51. data/lib/vagrant/hosts/base.rb +77 -0
  52. data/lib/vagrant/hosts/bsd.rb +53 -0
  53. data/lib/vagrant/hosts/linux.rb +52 -0
  54. data/lib/vagrant/provisioners/base.rb +17 -9
  55. data/lib/vagrant/provisioners/chef.rb +1 -1
  56. data/lib/vagrant/provisioners/chef_server.rb +4 -8
  57. data/lib/vagrant/provisioners/chef_solo.rb +1 -2
  58. data/lib/vagrant/ssh.rb +12 -4
  59. data/lib/vagrant/systems/base.rb +4 -0
  60. data/lib/vagrant/systems/linux.rb +12 -1
  61. data/lib/vagrant/util.rb +16 -0
  62. data/lib/vagrant/util/busy.rb +59 -0
  63. data/lib/vagrant/util/plain_logger.rb +11 -0
  64. data/lib/vagrant/util/platform.rb +18 -0
  65. data/lib/vagrant/util/resource_logger.rb +128 -0
  66. data/lib/vagrant/version.rb +6 -0
  67. data/lib/vagrant/vm.rb +10 -12
  68. data/templates/chef_solo_solo.erb +2 -1
  69. data/templates/nfs/exports.erb +3 -0
  70. data/templates/nfs/exports_linux.erb +3 -0
  71. data/templates/strings.yml +23 -3
  72. metadata +121 -196
  73. data/.gitignore +0 -11
  74. data/Gemfile +0 -18
  75. data/Rakefile +0 -41
  76. data/VERSION +0 -1
  77. data/bin/.gitignore +0 -0
  78. data/lib/vagrant/actions/base.rb +0 -130
  79. data/lib/vagrant/actions/box/add.rb +0 -23
  80. data/lib/vagrant/actions/box/destroy.rb +0 -14
  81. data/lib/vagrant/actions/box/download.rb +0 -67
  82. data/lib/vagrant/actions/box/unpackage.rb +0 -42
  83. data/lib/vagrant/actions/box/verify.rb +0 -32
  84. data/lib/vagrant/actions/collection.rb +0 -36
  85. data/lib/vagrant/actions/runner.rb +0 -131
  86. data/lib/vagrant/actions/vm/boot.rb +0 -43
  87. data/lib/vagrant/actions/vm/customize.rb +0 -19
  88. data/lib/vagrant/actions/vm/destroy.rb +0 -24
  89. data/lib/vagrant/actions/vm/down.rb +0 -22
  90. data/lib/vagrant/actions/vm/export.rb +0 -45
  91. data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
  92. data/lib/vagrant/actions/vm/halt.rb +0 -24
  93. data/lib/vagrant/actions/vm/import.rb +0 -23
  94. data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
  95. data/lib/vagrant/actions/vm/package.rb +0 -94
  96. data/lib/vagrant/actions/vm/provision.rb +0 -49
  97. data/lib/vagrant/actions/vm/reload.rb +0 -17
  98. data/lib/vagrant/actions/vm/resume.rb +0 -16
  99. data/lib/vagrant/actions/vm/start.rb +0 -26
  100. data/lib/vagrant/actions/vm/suspend.rb +0 -16
  101. data/lib/vagrant/actions/vm/up.rb +0 -53
  102. data/lib/vagrant/busy.rb +0 -79
  103. data/lib/vagrant/resource_logger.rb +0 -126
  104. data/lib/vagrant/util/error_helper.rb +0 -13
  105. data/lib/vagrant/util/output_helper.rb +0 -9
  106. data/test/test_helper.rb +0 -149
  107. data/test/vagrant/actions/base_test.rb +0 -32
  108. data/test/vagrant/actions/box/add_test.rb +0 -36
  109. data/test/vagrant/actions/box/destroy_test.rb +0 -17
  110. data/test/vagrant/actions/box/download_test.rb +0 -137
  111. data/test/vagrant/actions/box/unpackage_test.rb +0 -99
  112. data/test/vagrant/actions/box/verify_test.rb +0 -44
  113. data/test/vagrant/actions/collection_test.rb +0 -113
  114. data/test/vagrant/actions/runner_test.rb +0 -268
  115. data/test/vagrant/actions/vm/boot_test.rb +0 -49
  116. data/test/vagrant/actions/vm/customize_test.rb +0 -21
  117. data/test/vagrant/actions/vm/destroy_test.rb +0 -37
  118. data/test/vagrant/actions/vm/down_test.rb +0 -39
  119. data/test/vagrant/actions/vm/export_test.rb +0 -88
  120. data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
  121. data/test/vagrant/actions/vm/halt_test.rb +0 -65
  122. data/test/vagrant/actions/vm/import_test.rb +0 -45
  123. data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
  124. data/test/vagrant/actions/vm/network_test.rb +0 -291
  125. data/test/vagrant/actions/vm/package_test.rb +0 -254
  126. data/test/vagrant/actions/vm/provision_test.rb +0 -99
  127. data/test/vagrant/actions/vm/reload_test.rb +0 -46
  128. data/test/vagrant/actions/vm/resume_test.rb +0 -26
  129. data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
  130. data/test/vagrant/actions/vm/start_test.rb +0 -73
  131. data/test/vagrant/actions/vm/suspend_test.rb +0 -26
  132. data/test/vagrant/actions/vm/up_test.rb +0 -96
  133. data/test/vagrant/active_list_test.rb +0 -173
  134. data/test/vagrant/box_test.rb +0 -154
  135. data/test/vagrant/busy_test.rb +0 -78
  136. data/test/vagrant/command_test.rb +0 -53
  137. data/test/vagrant/commands/base_test.rb +0 -139
  138. data/test/vagrant/commands/box/add_test.rb +0 -34
  139. data/test/vagrant/commands/box/list_test.rb +0 -32
  140. data/test/vagrant/commands/box/remove_test.rb +0 -41
  141. data/test/vagrant/commands/destroy_test.rb +0 -44
  142. data/test/vagrant/commands/halt_test.rb +0 -50
  143. data/test/vagrant/commands/init_test.rb +0 -55
  144. data/test/vagrant/commands/package_test.rb +0 -104
  145. data/test/vagrant/commands/provision_test.rb +0 -60
  146. data/test/vagrant/commands/reload_test.rb +0 -44
  147. data/test/vagrant/commands/resume_test.rb +0 -44
  148. data/test/vagrant/commands/ssh_config_test.rb +0 -77
  149. data/test/vagrant/commands/ssh_test.rb +0 -129
  150. data/test/vagrant/commands/status_test.rb +0 -40
  151. data/test/vagrant/commands/suspend_test.rb +0 -44
  152. data/test/vagrant/commands/up_test.rb +0 -47
  153. data/test/vagrant/config_test.rb +0 -287
  154. data/test/vagrant/downloaders/base_test.rb +0 -28
  155. data/test/vagrant/downloaders/file_test.rb +0 -33
  156. data/test/vagrant/downloaders/http_test.rb +0 -62
  157. data/test/vagrant/environment_test.rb +0 -770
  158. data/test/vagrant/provisioners/base_test.rb +0 -33
  159. data/test/vagrant/provisioners/chef_server_test.rb +0 -176
  160. data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
  161. data/test/vagrant/provisioners/chef_test.rb +0 -175
  162. data/test/vagrant/resource_logger_test.rb +0 -145
  163. data/test/vagrant/ssh_session_test.rb +0 -46
  164. data/test/vagrant/ssh_test.rb +0 -296
  165. data/test/vagrant/systems/linux_test.rb +0 -179
  166. data/test/vagrant/util/error_helper_test.rb +0 -5
  167. data/test/vagrant/util/output_helper_test.rb +0 -5
  168. data/test/vagrant/util/plain_logger_test.rb +0 -17
  169. data/test/vagrant/util/platform_test.rb +0 -18
  170. data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
  171. data/test/vagrant/util/template_renderer_test.rb +0 -144
  172. data/test/vagrant/util/translator_test.rb +0 -61
  173. data/test/vagrant/util_test.rb +0 -27
  174. data/test/vagrant/vm_test.rb +0 -235
  175. data/vagrant.gemspec +0 -291
@@ -1,268 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
-
3
- class ActionRunnerTest < Test::Unit::TestCase
4
- class MockAction; end
5
- class MockActionOther; end
6
-
7
- def mock_fake_action(action_klass = nil, runner = nil)
8
- action = action_klass ? action_klass.new(runner) : mock("action")
9
- action.stubs(:prepare)
10
- action.stubs(:execute!)
11
- action.stubs(:cleanup)
12
- stub_default_action_dependecies(action)
13
- action
14
- end
15
-
16
- context "callbacks" do
17
- setup do
18
- @runner = Vagrant::Actions::Runner.new
19
- end
20
-
21
- context "around callbacks" do
22
- should "invoke before/after_name for around callbacks" do
23
- block_obj = mock("block_obj")
24
- around_seq = sequence("around_seq")
25
- @runner.expects(:invoke_callback).with(:before_foo).once.in_sequence(around_seq)
26
- block_obj.expects(:foo).once.in_sequence(around_seq)
27
- @runner.expects(:invoke_callback).with(:after_foo).once.in_sequence(around_seq)
28
-
29
- @runner.invoke_around_callback(:foo) do
30
- block_obj.foo
31
- end
32
- end
33
-
34
- should "forward arguments to invoke_callback" do
35
- @runner.expects(:invoke_callback).with(:before_foo, "foo").once
36
- @runner.expects(:invoke_callback).with(:after_foo, "foo").once
37
- @runner.invoke_around_callback(:foo, "foo") do; end
38
- end
39
- end
40
-
41
- should "not invoke callback on actions which don't respond to it" do
42
- action = mock("action")
43
- action.stubs(:respond_to?).with(:foo).returns(false)
44
- action.expects(:foo).never
45
-
46
- assert_nothing_raised do
47
- @runner.actions << action
48
- @runner.invoke_callback(:foo)
49
- end
50
- end
51
-
52
- should "invoke callback on actions which do respond to the method" do
53
- action = mock("action")
54
- action.expects(:foo).once
55
-
56
- @runner.actions << action
57
- @runner.invoke_callback(:foo)
58
- end
59
-
60
- should "collect all the results and return them as an array" do
61
- result = []
62
- 3.times do |i|
63
- action = mock("action#{i}")
64
- action.expects(:foo).returns("foo#{i}").once
65
-
66
- @runner.actions << action
67
- result << "foo#{i}"
68
- end
69
-
70
- assert_equal result, @runner.invoke_callback(:foo)
71
- end
72
- end
73
-
74
- context "finding actions" do
75
- setup do
76
- @runner = Vagrant::Actions::Runner.new
77
- end
78
-
79
- should "return nil if the action could not be found" do
80
- assert_nil @runner.find_action(Vagrant::Actions::VM::Export)
81
- end
82
-
83
- should "return the first instance of the action found" do
84
- @runner.add_action(Vagrant::Actions::VM::Export)
85
- @runner.add_action(Vagrant::Actions::VM::Export)
86
-
87
- assert @runner.actions[0].equal?(@runner.find_action(Vagrant::Actions::VM::Export))
88
- end
89
- end
90
-
91
- context "adding actions" do
92
- setup do
93
- @runner = Vagrant::Actions::Runner.new
94
- end
95
-
96
- should "initialize the action when added" do
97
- action_klass = mock("action_class")
98
- action_inst = mock("action_inst")
99
- action_klass.expects(:new).once.returns(action_inst)
100
- @runner.add_action(action_klass)
101
- assert_equal 1, @runner.actions.length
102
- end
103
-
104
- should "initialize the action with given arguments when added" do
105
- action_klass = mock("action_class")
106
- action_klass.expects(:new).with(@runner, "foo", "bar").once
107
- @runner.add_action(action_klass, "foo", "bar")
108
- end
109
- end
110
-
111
- context "class method execute" do
112
- should "run actions on class method execute!" do
113
- vm = mock("vm")
114
- execute_seq = sequence("execute_seq")
115
- Vagrant::Actions::Runner.expects(:new).returns(vm).in_sequence(execute_seq)
116
- vm.expects(:add_action).with("foo").in_sequence(execute_seq)
117
- vm.expects(:execute!).once.in_sequence(execute_seq)
118
-
119
- Vagrant::Actions::Runner.execute!("foo")
120
- end
121
-
122
- should "forward arguments to add_action on class method execute!" do
123
- vm = mock("vm")
124
- execute_seq = sequence("execute_seq")
125
- Vagrant::Actions::Runner.expects(:new).returns(vm).in_sequence(execute_seq)
126
- vm.expects(:add_action).with("foo", "bar", "baz").in_sequence(execute_seq)
127
- vm.expects(:execute!).once.in_sequence(execute_seq)
128
-
129
- Vagrant::Actions::Runner.execute!("foo", "bar", "baz")
130
- end
131
- end
132
-
133
- context "instance method execute" do
134
- setup do
135
- @runner = Vagrant::Actions::Runner.new
136
- @runner.stubs(:action_klasses).returns([Vagrant::Actions::Base])
137
- end
138
-
139
- should "clear the actions and run a single action if given to execute!" do
140
- action = mock("action")
141
- run_action = mock("action_run")
142
- stub_default_action_dependecies(run_action)
143
- run_class = mock("run_class")
144
- run_class.expects(:new).once.returns(run_action)
145
- @runner.actions << action
146
-
147
- [:prepare, :execute!, :cleanup].each do |method|
148
- action.expects(method).never
149
- run_action.expects(method).once
150
- end
151
-
152
- @runner.execute!(run_class)
153
- end
154
-
155
- should "clear actions after running execute!" do
156
- @runner.actions << mock_fake_action
157
- assert !@runner.actions.empty? # sanity
158
- @runner.execute!
159
- assert @runner.actions.empty?
160
- end
161
-
162
- should "run #prepare on all actions, then #execute!" do
163
- action_seq = sequence("action_seq")
164
- actions = []
165
- [MockAction, MockActionOther].each_with_index do |klass, i|
166
- action = mock("action#{i}")
167
- action.expects(:class).returns(klass)
168
- stub_default_action_dependecies(action)
169
- @runner.actions << action
170
- actions << action
171
- end
172
-
173
- [:prepare, :execute!, :cleanup].each do |method|
174
- actions.each do |action|
175
- action.expects(method).once.in_sequence(action_seq)
176
- end
177
- end
178
-
179
- @runner.execute!
180
- end
181
-
182
- context "exceptions" do
183
- setup do
184
- @actions = [MockAction, MockActionOther].map do |klass|
185
- action = mock_fake_action
186
- action.expects(:class).returns(klass)
187
- action.stubs(:rescue)
188
- @runner.actions << action
189
- action
190
- end
191
-
192
- @exception = Exception.new
193
- end
194
-
195
- should "call #rescue on each action if an exception is raised during execute!" do
196
- @actions.each do |a|
197
- a.expects(:rescue).with(@exception).once
198
- end
199
-
200
- @actions[0].stubs(:execute!).raises(@exception)
201
-
202
- @runner.expects(:error_and_exit).never
203
- assert_raises(Exception) { @runner.execute! }
204
- end
205
-
206
- should "call #rescue on each action if an exception is raised during prepare" do
207
- @actions.each do |a|
208
- a.expects(:rescue).with(@exception).once
209
- end
210
-
211
- @actions[0].stubs(:prepare).raises(@exception)
212
-
213
- @runner.expects(:error_and_exit).never
214
- assert_raises(Exception) { @runner.execute! }
215
- end
216
-
217
- should "call error_and_exit if it is an ActionException" do
218
- @exception = Vagrant::Actions::ActionException.new("foo")
219
- @actions[0].stubs(:prepare).raises(@exception)
220
-
221
- @runner.expects(:error_and_exit).with(@exception.key, @exception.data).once
222
- @runner.execute!
223
- end
224
- end
225
- end
226
-
227
- context "actions" do
228
- setup do
229
- @runner = Vagrant::Actions::Runner.new
230
- end
231
-
232
- should "setup actions to be an array" do
233
- assert_nil @runner.instance_variable_get(:@actions)
234
- actions = @runner.actions
235
- assert actions.is_a?(Array)
236
- assert actions.equal?(@runner.actions)
237
- end
238
-
239
- should "be empty initially" do
240
- assert @runner.actions.empty?
241
- end
242
- end
243
-
244
- context "duplicate action exceptions" do
245
- setup do
246
- @runner = Vagrant::Actions::Runner.new
247
- end
248
-
249
- should "should be raised when a duplicate is added" do
250
- action = mock_fake_action
251
- 2.times {@runner.actions << action }
252
- assert_raise Vagrant::Actions::DuplicateActionException do
253
- @runner.execute!
254
- end
255
- end
256
-
257
- should "should not be raise when no duplicate actions are present" do
258
- @runner.actions << mock_fake_action(Vagrant::Actions::Base, @runner)
259
- @runner.actions << mock_fake_action(Vagrant::Actions::VM::Halt, @runner)
260
-
261
- assert_nothing_raised { @runner.execute! }
262
- end
263
-
264
- should "should not raise when a single action is specified" do
265
- assert_nothing_raised { @runner.execute!(Vagrant::Actions::Base) }
266
- end
267
- end
268
- end
@@ -1,49 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class BootActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Boot)
6
- @runner.stubs(:invoke_callback)
7
- end
8
-
9
- context "execution" do
10
- should "invoke the 'boot' around callback" do
11
- boot_seq = sequence("boot_seq")
12
- @runner.expects(:invoke_around_callback).with(:boot).once.in_sequence(boot_seq).yields
13
- @action.expects(:boot).in_sequence(boot_seq)
14
- @action.expects(:wait_for_boot).returns(true).in_sequence(boot_seq)
15
- @action.execute!
16
- end
17
-
18
- should "error and exit if the bootup failed" do
19
- fail_boot_seq = sequence("fail_boot_seq")
20
- @action.expects(:boot).once.in_sequence(fail_boot_seq)
21
- @action.expects(:wait_for_boot).returns(false).in_sequence(fail_boot_seq)
22
- @action.expects(:error_and_exit).with(:vm_failed_to_boot).once.in_sequence(fail_boot_seq)
23
- @action.execute!
24
- end
25
- end
26
-
27
- context "booting" do
28
- should "start the VM in specified mode" do
29
- mode = mock("boot_mode")
30
- @runner.env.config.vm.boot_mode = mode
31
- @vm.expects(:start).with(mode).once
32
- @action.boot
33
- end
34
- end
35
-
36
- context "waiting for boot" do
37
- should "repeatedly ping the SSH port and return false with no response" do
38
- seq = sequence('pings')
39
- @runner.ssh.expects(:up?).times(@runner.env.config.ssh.max_tries.to_i - 1).returns(false).in_sequence(seq)
40
- @runner.ssh.expects(:up?).once.returns(true).in_sequence(seq)
41
- assert @action.wait_for_boot(0)
42
- end
43
-
44
- should "ping the max number of times then just return" do
45
- @runner.ssh.expects(:up?).times(@runner.env.config.ssh.max_tries.to_i).returns(false)
46
- assert !@action.wait_for_boot(0)
47
- end
48
- end
49
- end
@@ -1,21 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class CustomizeActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Customize)
6
- end
7
-
8
- context "executing" do
9
- should "run the VM customization procs then save the VM" do
10
- @runner.env.config.vm.customize { |vm| }
11
- @runner.env.config.vm.expects(:run_procs!).with(@vm)
12
- @vm.expects(:save).once
13
- @action.execute!
14
- end
15
-
16
- should "not run anything if no customize blocks exist" do
17
- @vm.expects(:save).never
18
- @action.execute!
19
- end
20
- end
21
- end
@@ -1,37 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class DestroyActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Destroy)
6
- end
7
-
8
- context "executing" do
9
- should "invoke an around callback around the destroy" do
10
- @runner.expects(:invoke_around_callback).with(:destroy).once
11
- @action.execute!
12
- end
13
-
14
- should "destroy VM and clear persist" do
15
- @runner.stubs(:invoke_around_callback).yields
16
- clear_seq = sequence("clear")
17
- @action.expects(:destroy_vm).in_sequence(clear_seq)
18
- @action.expects(:update_dotfile).in_sequence(clear_seq)
19
- @action.execute!
20
- end
21
- end
22
-
23
- context "destroying the VM" do
24
- should "destroy VM and attached images" do
25
- @vm.expects(:destroy).with(:destroy_medium => :delete).once
26
- @runner.expects(:vm=).with(nil).once
27
- @action.destroy_vm
28
- end
29
- end
30
-
31
- context "updating the dotfile" do
32
- should "update the environment dotfile" do
33
- @runner.env.expects(:update_dotfile).once
34
- @action.update_dotfile
35
- end
36
- end
37
- end
@@ -1,39 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class DownActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Down)
6
- end
7
-
8
- context "preparing" do
9
- setup do
10
- @vm.stubs(:running?).returns(false)
11
- end
12
-
13
- def setup_action_expectations(order)
14
- default_seq = sequence("default_seq")
15
- order.each do |action|
16
- action = [action] unless action.is_a?(Array)
17
- @runner.expects(:add_action).with(action.shift, *action).once.in_sequence(default_seq)
18
- end
19
- end
20
-
21
- should "add the destroy action alone if VM is not running" do
22
- setup_action_expectations([Vagrant::Actions::VM::Network, Vagrant::Actions::VM::Destroy])
23
- @action.prepare
24
- end
25
-
26
- should "add the halt action if the VM is running" do
27
- @vm.expects(:running?).returns(true)
28
- setup_action_expectations([[Vagrant::Actions::VM::Halt, {:force => true}], Vagrant::Actions::VM::Network, Vagrant::Actions::VM::Destroy])
29
- @action.prepare
30
- end
31
- end
32
-
33
- context "after halting" do
34
- should "sleep" do
35
- Kernel.expects(:sleep).once
36
- @action.after_halt
37
- end
38
- end
39
- end
@@ -1,88 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class ExportActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Export)
6
- @action.stubs(:complete_progress)
7
- end
8
-
9
- context "executing" do
10
- should "setup the temp dir then export" do
11
- exec_seq = sequence('execute')
12
- @action.expects(:setup_temp_dir).once.in_sequence(exec_seq)
13
- @action.expects(:export).once.in_sequence(exec_seq)
14
- @action.execute!
15
- end
16
- end
17
-
18
- context "setting up the temporary directory" do
19
- setup do
20
- @time_now = Time.now.to_i.to_s
21
- Time.stubs(:now).returns(@time_now)
22
-
23
- @tmp_path = "foo"
24
- @runner.env.stubs(:tmp_path).returns(@tmp_path)
25
-
26
- @temp_dir = File.join(@runner.env.tmp_path, @time_now)
27
- FileUtils.stubs(:mkpath)
28
- end
29
-
30
- should "create the temporary directory using the current time" do
31
- FileUtils.expects(:mkpath).with(@temp_dir).once
32
- @action.setup_temp_dir
33
- end
34
-
35
- should "set the temporary directory to the temp_dir variable" do
36
- @action.setup_temp_dir
37
- assert_equal @temp_dir, @action.temp_dir
38
- end
39
- end
40
-
41
- context "path to OVF file" do
42
- setup do
43
- @temp_dir = "foo"
44
- @action.stubs(:temp_dir).returns(@temp_dir)
45
- end
46
-
47
- should "be the temporary directory joined with the OVF filename" do
48
- assert_equal File.join(@temp_dir, @runner.env.config.vm.box_ovf), @action.ovf_path
49
- end
50
- end
51
-
52
- context "exporting" do
53
- setup do
54
- @ovf_path = mock("ovf_path")
55
- @action.stubs(:ovf_path).returns(@ovf_path)
56
- end
57
-
58
- should "call export on the runner with the ovf path" do
59
- @vm.expects(:export).with(@ovf_path).once
60
- @action.export
61
- end
62
- end
63
-
64
- context "cleanup" do
65
- setup do
66
- @temp_dir = "foo"
67
- @action.stubs(:temp_dir).returns(@temp_dir)
68
- end
69
-
70
- should "remove the temporary directory" do
71
- FileUtils.expects(:rm_r).with(@temp_dir).once
72
- @action.cleanup
73
- end
74
-
75
- should "not remove a directory if temp_dir is nil" do
76
- FileUtils.expects(:rm_r).never
77
- @action.stubs(:temp_dir).returns(nil)
78
- @action.cleanup
79
- end
80
- end
81
-
82
- context "rescue" do
83
- should "call cleanup method" do
84
- @action.expects(:cleanup).once
85
- @action.rescue(nil)
86
- end
87
- end
88
- end