vagrant 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +56 -0
  4. data/Gemfile +14 -3
  5. data/Gemfile.lock +38 -11
  6. data/README.md +1 -1
  7. data/bin/vagrant +20 -5
  8. data/config/default.rb +6 -8
  9. data/lib/vagrant.rb +40 -13
  10. data/lib/vagrant/action.rb +56 -16
  11. data/lib/vagrant/action/box/destroy.rb +3 -1
  12. data/lib/vagrant/action/box/download.rb +8 -13
  13. data/lib/vagrant/action/box/unpackage.rb +8 -11
  14. data/lib/vagrant/action/box/verify.rb +3 -3
  15. data/lib/vagrant/action/builder.rb +3 -30
  16. data/lib/vagrant/action/builtin.rb +6 -1
  17. data/lib/vagrant/action/environment.rb +14 -62
  18. data/lib/vagrant/action/general/package.rb +29 -22
  19. data/lib/vagrant/action/vm/boot.rb +5 -12
  20. data/lib/vagrant/action/vm/check_box.rb +4 -4
  21. data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
  22. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
  23. data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
  24. data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
  25. data/lib/vagrant/action/vm/customize.rb +1 -1
  26. data/lib/vagrant/action/vm/destroy.rb +1 -2
  27. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
  28. data/lib/vagrant/action/vm/disable_networks.rb +11 -9
  29. data/lib/vagrant/action/vm/discard_state.rb +2 -2
  30. data/lib/vagrant/action/vm/export.rb +10 -11
  31. data/lib/vagrant/action/vm/forward_ports.rb +21 -9
  32. data/lib/vagrant/action/vm/halt.rb +3 -8
  33. data/lib/vagrant/action/vm/import.rb +16 -14
  34. data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
  35. data/lib/vagrant/action/vm/network.rb +9 -16
  36. data/lib/vagrant/action/vm/nfs.rb +14 -18
  37. data/lib/vagrant/action/vm/provision.rb +5 -5
  38. data/lib/vagrant/action/vm/resume.rb +1 -1
  39. data/lib/vagrant/action/vm/share_folders.rb +6 -44
  40. data/lib/vagrant/action/vm/suspend.rb +1 -1
  41. data/lib/vagrant/action/warden.rb +74 -0
  42. data/lib/vagrant/box.rb +18 -82
  43. data/lib/vagrant/box_collection.rb +47 -0
  44. data/lib/vagrant/cli.rb +55 -0
  45. data/lib/vagrant/command/base.rb +106 -0
  46. data/lib/vagrant/command/box.rb +33 -0
  47. data/lib/vagrant/command/destroy.rb +17 -0
  48. data/lib/vagrant/command/group_base.rb +99 -0
  49. data/lib/vagrant/command/halt.rb +18 -0
  50. data/lib/vagrant/command/helpers.rb +33 -0
  51. data/lib/vagrant/command/init.rb +14 -0
  52. data/lib/vagrant/command/named_base.rb +14 -0
  53. data/lib/vagrant/command/package.rb +41 -0
  54. data/lib/vagrant/command/provision.rb +17 -0
  55. data/lib/vagrant/command/reload.rb +17 -0
  56. data/lib/vagrant/command/resume.rb +17 -0
  57. data/lib/vagrant/command/ssh.rb +41 -0
  58. data/lib/vagrant/command/ssh_config.rb +21 -0
  59. data/lib/vagrant/command/status.rb +23 -0
  60. data/lib/vagrant/command/suspend.rb +17 -0
  61. data/lib/vagrant/command/up.rb +20 -0
  62. data/lib/vagrant/command/upgrade_to_060.rb +45 -0
  63. data/lib/vagrant/command/version.rb +13 -0
  64. data/lib/vagrant/config.rb +107 -189
  65. data/lib/vagrant/config/base.rb +67 -0
  66. data/lib/vagrant/config/error_recorder.rb +19 -0
  67. data/lib/vagrant/config/nfs.rb +10 -0
  68. data/lib/vagrant/config/package.rb +9 -0
  69. data/lib/vagrant/config/ssh.rb +28 -0
  70. data/lib/vagrant/config/vagrant.rb +21 -0
  71. data/lib/vagrant/config/vm.rb +111 -0
  72. data/lib/vagrant/data_store.rb +68 -0
  73. data/lib/vagrant/downloaders/file.rb +3 -3
  74. data/lib/vagrant/downloaders/http.rb +5 -5
  75. data/lib/vagrant/environment.rb +246 -243
  76. data/lib/vagrant/errors.rb +306 -0
  77. data/lib/vagrant/hosts/base.rb +1 -1
  78. data/lib/vagrant/hosts/bsd.rb +3 -9
  79. data/lib/vagrant/hosts/linux.rb +3 -9
  80. data/lib/vagrant/plugin.rb +50 -0
  81. data/lib/vagrant/provisioners/base.rb +0 -6
  82. data/lib/vagrant/provisioners/chef.rb +63 -58
  83. data/lib/vagrant/provisioners/chef_server.rb +9 -11
  84. data/lib/vagrant/provisioners/chef_solo.rb +2 -2
  85. data/lib/vagrant/ssh.rb +34 -37
  86. data/lib/vagrant/systems/base.rb +0 -13
  87. data/lib/vagrant/systems/linux.rb +10 -33
  88. data/lib/vagrant/systems/solaris.rb +59 -0
  89. data/lib/vagrant/test_helpers.rb +109 -0
  90. data/lib/vagrant/ui.rb +65 -0
  91. data/lib/vagrant/util.rb +9 -19
  92. data/lib/vagrant/util/glob_loader.rb +19 -17
  93. data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
  94. data/lib/vagrant/util/plain_logger.rb +2 -0
  95. data/lib/vagrant/util/platform.rb +2 -0
  96. data/lib/vagrant/util/resource_logger.rb +5 -70
  97. data/lib/vagrant/util/retryable.rb +25 -0
  98. data/lib/vagrant/util/template_renderer.rb +1 -1
  99. data/lib/vagrant/version.rb +1 -1
  100. data/lib/vagrant/vm.rb +27 -13
  101. data/templates/commands/init/Vagrantfile.erb +13 -0
  102. data/templates/config/validation_failed.erb +7 -0
  103. data/templates/locales/en.yml +402 -0
  104. data/templates/package_Vagrantfile.erb +1 -1
  105. data/test/locales/en.yml +8 -0
  106. data/test/test_helper.rb +19 -103
  107. data/test/vagrant/action/box/destroy_test.rb +7 -19
  108. data/test/vagrant/action/box/download_test.rb +9 -25
  109. data/test/vagrant/action/box/package_test.rb +2 -2
  110. data/test/vagrant/action/box/unpackage_test.rb +8 -34
  111. data/test/vagrant/action/box/verify_test.rb +10 -19
  112. data/test/vagrant/action/builder_test.rb +0 -15
  113. data/test/vagrant/action/env/set_test.rb +1 -1
  114. data/test/vagrant/action/environment_test.rb +8 -26
  115. data/test/vagrant/action/general/package_test.rb +53 -53
  116. data/test/vagrant/action/vm/boot_test.rb +5 -22
  117. data/test/vagrant/action/vm/check_box_test.rb +35 -25
  118. data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
  119. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
  120. data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
  121. data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
  122. data/test/vagrant/action/vm/customize_test.rb +2 -1
  123. data/test/vagrant/action/vm/destroy_test.rb +1 -2
  124. data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
  125. data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
  126. data/test/vagrant/action/vm/discard_state_test.rb +10 -1
  127. data/test/vagrant/action/vm/export_test.rb +9 -37
  128. data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
  129. data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
  130. data/test/vagrant/action/vm/halt_test.rb +11 -1
  131. data/test/vagrant/action/vm/import_test.rb +37 -21
  132. data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
  133. data/test/vagrant/action/vm/network_test.rb +8 -7
  134. data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
  135. data/test/vagrant/action/vm/nfs_test.rb +20 -45
  136. data/test/vagrant/action/vm/package_test.rb +1 -1
  137. data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
  138. data/test/vagrant/action/vm/provision_test.rb +10 -17
  139. data/test/vagrant/action/vm/resume_test.rb +1 -1
  140. data/test/vagrant/action/vm/share_folders_test.rb +25 -106
  141. data/test/vagrant/action/vm/suspend_test.rb +1 -1
  142. data/test/vagrant/action/warden_test.rb +105 -0
  143. data/test/vagrant/action_test.rb +5 -27
  144. data/test/vagrant/box_collection_test.rb +44 -0
  145. data/test/vagrant/box_test.rb +5 -105
  146. data/test/vagrant/cli_test.rb +35 -0
  147. data/test/vagrant/command/base_test.rb +23 -0
  148. data/test/vagrant/command/group_base_test.rb +15 -0
  149. data/test/vagrant/command/helpers_test.rb +88 -0
  150. data/test/vagrant/config/base_test.rb +52 -0
  151. data/test/vagrant/config/error_recorder_test.rb +18 -0
  152. data/test/vagrant/config/ssh_test.rb +12 -0
  153. data/test/vagrant/config/vagrant_test.rb +11 -0
  154. data/test/vagrant/config/vm_test.rb +70 -0
  155. data/test/vagrant/config_test.rb +113 -206
  156. data/test/vagrant/data_store_test.rb +68 -0
  157. data/test/vagrant/downloaders/base_test.rb +1 -1
  158. data/test/vagrant/downloaders/file_test.rb +4 -3
  159. data/test/vagrant/downloaders/http_test.rb +14 -4
  160. data/test/vagrant/environment_test.rb +290 -590
  161. data/test/vagrant/errors_test.rb +42 -0
  162. data/test/vagrant/hosts/base_test.rb +1 -1
  163. data/test/vagrant/hosts/bsd_test.rb +3 -6
  164. data/test/vagrant/hosts/linux_test.rb +3 -5
  165. data/test/vagrant/plugin_test.rb +9 -0
  166. data/test/vagrant/provisioners/base_test.rb +1 -1
  167. data/test/vagrant/provisioners/chef_server_test.rb +31 -35
  168. data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
  169. data/test/vagrant/provisioners/chef_test.rb +7 -7
  170. data/test/vagrant/ssh_session_test.rb +3 -10
  171. data/test/vagrant/ssh_test.rb +25 -33
  172. data/test/vagrant/systems/linux_test.rb +6 -71
  173. data/test/vagrant/ui_test.rb +29 -0
  174. data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
  175. data/test/vagrant/util/resource_logger_test.rb +14 -81
  176. data/test/vagrant/util/retryable_test.rb +38 -0
  177. data/test/vagrant/util/template_renderer_test.rb +4 -4
  178. data/test/vagrant/vm_test.rb +47 -26
  179. data/vagrant.gemspec +14 -12
  180. metadata +142 -108
  181. data/bin/.gitignore +0 -0
  182. data/lib/vagrant/action/action_exception.rb +0 -16
  183. data/lib/vagrant/action/env/error_halt.rb +0 -16
  184. data/lib/vagrant/action/exception_catcher.rb +0 -14
  185. data/lib/vagrant/action/vm/persist.rb +0 -22
  186. data/lib/vagrant/active_list.rb +0 -83
  187. data/lib/vagrant/command.rb +0 -27
  188. data/lib/vagrant/commands/base.rb +0 -181
  189. data/lib/vagrant/commands/box.rb +0 -16
  190. data/lib/vagrant/commands/box/add.rb +0 -30
  191. data/lib/vagrant/commands/box/list.rb +0 -30
  192. data/lib/vagrant/commands/box/remove.rb +0 -30
  193. data/lib/vagrant/commands/box/repackage.rb +0 -35
  194. data/lib/vagrant/commands/destroy.rb +0 -37
  195. data/lib/vagrant/commands/halt.rb +0 -43
  196. data/lib/vagrant/commands/init.rb +0 -36
  197. data/lib/vagrant/commands/package.rb +0 -81
  198. data/lib/vagrant/commands/provision.rb +0 -31
  199. data/lib/vagrant/commands/reload.rb +0 -36
  200. data/lib/vagrant/commands/resume.rb +0 -35
  201. data/lib/vagrant/commands/ssh.rb +0 -78
  202. data/lib/vagrant/commands/ssh_config.rb +0 -45
  203. data/lib/vagrant/commands/status.rb +0 -125
  204. data/lib/vagrant/commands/suspend.rb +0 -36
  205. data/lib/vagrant/commands/up.rb +0 -44
  206. data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
  207. data/lib/vagrant/util/translator.rb +0 -35
  208. data/templates/strings.yml +0 -341
  209. data/templates/unison/crontab_entry.erb +0 -1
  210. data/templates/unison/script.erb +0 -71
  211. data/test/vagrant/action/env/error_halt_test.rb +0 -21
  212. data/test/vagrant/action/exception_catcher_test.rb +0 -30
  213. data/test/vagrant/action/vm/persist_test.rb +0 -50
  214. data/test/vagrant/active_list_test.rb +0 -173
  215. data/test/vagrant/command_test.rb +0 -53
  216. data/test/vagrant/commands/base_test.rb +0 -139
  217. data/test/vagrant/commands/box/add_test.rb +0 -34
  218. data/test/vagrant/commands/box/list_test.rb +0 -32
  219. data/test/vagrant/commands/box/remove_test.rb +0 -41
  220. data/test/vagrant/commands/box/repackage_test.rb +0 -52
  221. data/test/vagrant/commands/destroy_test.rb +0 -44
  222. data/test/vagrant/commands/halt_test.rb +0 -50
  223. data/test/vagrant/commands/init_test.rb +0 -71
  224. data/test/vagrant/commands/package_test.rb +0 -97
  225. data/test/vagrant/commands/provision_test.rb +0 -60
  226. data/test/vagrant/commands/reload_test.rb +0 -47
  227. data/test/vagrant/commands/resume_test.rb +0 -44
  228. data/test/vagrant/commands/ssh_config_test.rb +0 -77
  229. data/test/vagrant/commands/ssh_test.rb +0 -129
  230. data/test/vagrant/commands/status_test.rb +0 -40
  231. data/test/vagrant/commands/suspend_test.rb +0 -44
  232. data/test/vagrant/commands/up_test.rb +0 -49
  233. data/test/vagrant/util/translator_test.rb +0 -61
  234. data/test/vagrant/util_test.rb +0 -27
@@ -1,34 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsBoxAddTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Box::Add
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
- setup do
19
- @name = "foo"
20
- @path = "bar"
21
- end
22
-
23
- should "execute the add action with the name and path" do
24
- Vagrant::Box.expects(:add).with(@env, @name, @path).once
25
- @instance.execute([@name, @path])
26
- end
27
-
28
- should "show help if not enough arguments" do
29
- Vagrant::Box.expects(:add).never
30
- @instance.expects(:show_help).once
31
- @instance.execute([])
32
- end
33
- end
34
- end
@@ -1,32 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsBoxListTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Box::List
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
- setup do
19
- @boxes = ["foo", "bar"]
20
-
21
- Vagrant::Box.stubs(:all).returns(@boxes)
22
- @instance.stubs(:wrap_output)
23
- end
24
-
25
- should "call all on box and sort the results" do
26
- @all = mock("all")
27
- @all.expects(:sort).returns(@boxes)
28
- Vagrant::Box.expects(:all).with(@env).returns(@all)
29
- @instance.execute
30
- end
31
- end
32
- end
@@ -1,41 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsBoxRemoveTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Box::Remove
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
- setup do
19
- @name = "foo"
20
- end
21
-
22
- should "show help if not enough arguments" do
23
- Vagrant::Box.expects(:find).never
24
- @instance.expects(:show_help).once
25
- @instance.execute([])
26
- end
27
-
28
- should "error and exit if the box doesn't exist" do
29
- Vagrant::Box.expects(:find).returns(nil)
30
- @instance.expects(:error_and_exit).with(:box_remove_doesnt_exist).once
31
- @instance.execute([@name])
32
- end
33
-
34
- should "call destroy on the box if it exists" do
35
- @box = mock("box")
36
- Vagrant::Box.expects(:find).with(@env, @name).returns(@box)
37
- @box.expects(:destroy).once
38
- @instance.execute([@name])
39
- end
40
- end
41
- end
@@ -1,52 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsBoxRepackageTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Box::Repackage
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
- setup do
19
- @name = "foo"
20
- end
21
-
22
- should "show help if not enough arguments" do
23
- Vagrant::Box.expects(:find).never
24
- @instance.expects(:show_help).once
25
- @instance.execute(["--include", "x,y,z"])
26
- end
27
-
28
- should "error and exit if the box doesn't exist" do
29
- Vagrant::Box.expects(:find).returns(nil)
30
- @instance.expects(:error_and_exit).with(:box_repackage_doesnt_exist).once
31
- @instance.execute([@name])
32
- end
33
-
34
- should "call repackage on the box if it exists" do
35
- @box = mock("box")
36
- Vagrant::Box.expects(:find).with(@env, @name).returns(@box)
37
- @box.expects(:repackage).once
38
- @instance.execute([@name])
39
- end
40
-
41
- should "pass given options into repackage" do
42
- @box = mock("box")
43
- Vagrant::Box.expects(:find).with(@env, @name).returns(@box)
44
- @box.expects(:repackage).once.with() do |opts|
45
- assert opts.is_a?(Hash)
46
- assert_equal "filename.box", opts["package.output"]
47
- true
48
- end
49
- @instance.execute([@name, "--output", "filename.box"])
50
- end
51
- end
52
- end
@@ -1,44 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsDestroyTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Destroy
6
-
7
- @env = mock_environment
8
-
9
- @instance = @klass.new(@env)
10
- end
11
-
12
- context "executing" do
13
- should "call all or single for the method" do
14
- @instance.expects(:all_or_single).with([], :destroy)
15
- @instance.execute
16
- end
17
- end
18
-
19
- context "destroying a single VM" do
20
- setup do
21
- @foo_vm = mock("vm")
22
- @foo_vm.stubs(:env).returns(@env)
23
- vms = { :foo => @foo_vm }
24
- @env.stubs(:vms).returns(vms)
25
- end
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.destroy_single(:foo)
30
- end
31
-
32
- should "destroy if its created" do
33
- @foo_vm.stubs(:created?).returns(true)
34
- @foo_vm.expects(:destroy).once
35
- @instance.destroy_single(:foo)
36
- end
37
-
38
- should "do nothing if its not created" do
39
- @foo_vm.stubs(:created?).returns(false)
40
- @foo_vm.expects(:destroy).never
41
- @instance.destroy_single(:foo)
42
- end
43
- end
44
- end
@@ -1,50 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsHaltTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Halt
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([], :halt)
14
- @instance.execute
15
- end
16
- end
17
-
18
- context "halting 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.halt_single(:foo)
30
- end
31
-
32
- should "halt if its created" do
33
- @foo_vm.stubs(:created?).returns(true)
34
- @foo_vm.expects(:halt).with(:force => false).once
35
- @instance.execute(["foo"])
36
- end
37
-
38
- should "halt and force if specified" do
39
- @foo_vm.stubs(:created?).returns(true)
40
- @foo_vm.expects(:halt).with(:force => true).once
41
- @instance.execute(["foo", "--force"])
42
- end
43
-
44
- should "do nothing if its not created" do
45
- @foo_vm.stubs(:created?).returns(false)
46
- @foo_vm.expects(:halt).never
47
- @instance.halt_single(:foo)
48
- end
49
- end
50
- end
@@ -1,71 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsInitTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Init
6
-
7
- @env = mock_environment
8
- @instance = @klass.new(@env)
9
- end
10
-
11
- context "execute" do
12
- should "create a vagrant file without any args" do
13
- args = []
14
- @instance.expects(:create_vagrantfile).with(:default_box => nil, :default_box_url => nil)
15
- @instance.execute(args)
16
- end
17
- context "when any arg is provided" do
18
- should "create the vagrant file using the first arg as default_box and the second as default_box_url" do
19
- args = []
20
- args[0] = "foo"
21
- args[1] = "foo.box"
22
-
23
- @instance.expects(:create_vagrantfile).with(:default_box => "foo", :default_box_url => "foo.box")
24
- @instance.execute(args)
25
- end
26
- end
27
- end
28
-
29
- context "creating the vagrantfile" do
30
- setup do
31
- @file = mock("file")
32
- @file.stubs(:write)
33
- File.stubs(:open).yields(@file)
34
- @rootfile_path = File.join(Dir.pwd, Vagrant::Environment::ROOTFILE_NAME)
35
-
36
- Vagrant::Util::TemplateRenderer.stubs(:render)
37
- end
38
-
39
- should "error and exit if a rootfile already exists" do
40
- File.expects(:exist?).with(@rootfile_path).returns(true)
41
- @instance.expects(:error_and_exit).with(:rootfile_already_exists).once
42
- @instance.create_vagrantfile
43
- end
44
-
45
- should "write to the rootfile path using the template renderer" do
46
- result = "foo"
47
- Vagrant::Util::TemplateRenderer.expects(:render).returns(result).once
48
- @file.expects(:write).with(result).once
49
- File.expects(:open).with(@rootfile_path, 'w+').yields(@file)
50
-
51
- @instance.create_vagrantfile
52
- end
53
-
54
- should "use the given base box if given" do
55
- box = "zooo"
56
- Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => box)
57
- @instance.create_vagrantfile :default_box => box
58
- end
59
-
60
- should "use the box_url if given" do
61
- box_url = "fubar.box"
62
- Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base", :default_box_url => "fubar.box")
63
- @instance.create_vagrantfile :default_box_url => box_url
64
- end
65
-
66
- should "use the default `base` if no box is given" do
67
- Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base")
68
- @instance.create_vagrantfile
69
- end
70
- end
71
- end
@@ -1,97 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsPackageTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Package
6
-
7
- @env = mock_environment
8
- @instance = @klass.new(@env)
9
- end
10
-
11
- context "executing" do
12
- should "package base if a base is given" do
13
- @instance.expects(:package_base).once
14
- @instance.execute(["--base","foo"])
15
- end
16
-
17
- should "package single if no name is given" do
18
- @instance.expects(:package_single).with(nil).once
19
- @instance.execute
20
- end
21
-
22
- should "package single if a name is given" do
23
- @instance.expects(:package_single).with("foo").once
24
- @instance.execute(["foo"])
25
- end
26
- end
27
-
28
- context "packaging base" do
29
- should "error and exit if no VM is found" do
30
- Vagrant::VM.expects(:find).with("foo", @instance.env).returns(nil)
31
- @instance.expects(:error_and_exit).with(:vm_base_not_found, :name => "foo").once
32
- @instance.execute(["--base", "foo"])
33
- end
34
-
35
- should "package the VM like any other VM" do
36
- vm = mock("vm")
37
- Vagrant::VM.expects(:find).with("foo", @instance.env).returns(vm)
38
- @instance.expects(:package_vm).with(vm).once
39
- @instance.execute(["--base", "foo"])
40
- end
41
- end
42
-
43
- context "packaging a single VM" do
44
- setup do
45
- @vm = mock("vm")
46
- @vm.stubs(:created?).returns(true)
47
-
48
- @vms = {:bar => @vm}
49
- @env.stubs(:vms).returns(@vms)
50
- @env.stubs(:multivm?).returns(false)
51
- end
52
-
53
- should "error and exit if no name is given in a multi-vm env" do
54
- @env.stubs(:multivm?).returns(true)
55
- @instance.expects(:error_and_exit).with(:package_multivm).once
56
- @instance.package_single(nil)
57
- end
58
-
59
- should "error and exit if the VM doesn't exist" do
60
- @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
61
- @instance.package_single(:foo)
62
- end
63
-
64
- should "error and exit if the VM is not created" do
65
- @vm.stubs(:created?).returns(false)
66
- @instance.expects(:error_and_exit).with(:environment_not_created).once
67
- @instance.package_single(:bar)
68
- end
69
-
70
- should "use the first VM is no name is given in a single VM environment" do
71
- @instance.expects(:package_vm).with(@vm).once
72
- @instance.package_single(nil)
73
- end
74
-
75
- should "package the VM" do
76
- @instance.expects(:package_vm).with(@vm).once
77
- @instance.package_single(:bar)
78
- end
79
- end
80
-
81
- context "packaging a VM" do
82
- setup do
83
- @vm = mock("vm")
84
-
85
- @options = {}
86
- @instance.stubs(:options).returns(@options)
87
- end
88
-
89
- should "package the VM with the proper arguments" do
90
- @options[:output] = "foo.box"
91
- @options[:include] = :bar
92
-
93
- @vm.expects(:package).with(@options).once
94
- @instance.package_vm(@vm)
95
- end
96
- end
97
- end
@@ -1,60 +0,0 @@
1
- require "test_helper"
2
-
3
- class CommandsProvisionTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Provision
6
- @env = mock_environment
7
- @instance = @klass.new(@env)
8
- end
9
-
10
- context "executing" do
11
- should "provision all if no name is given" do
12
- @instance.expects(:all_or_single).with([], :provision).once
13
- @instance.execute
14
- end
15
- end
16
-
17
- context "provisioning a single VM" do
18
- setup do
19
- @foo_vm = mock("vm")
20
- @foo_vm.stubs(:env).returns(@env)
21
- @foo_vm.stubs(:created?).returns(true)
22
-
23
- @vm_for_real = mock("vm for real")
24
- @foo_vm.stubs(:vm).returns(@vm_for_real)
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.execute(["foo"])
33
- end
34
-
35
- should "reload if it's running" do
36
- @vm_for_real.stubs(:running?).returns(true)
37
- @foo_vm.expects(:provision).once
38
- @instance.execute(["foo"])
39
- end
40
-
41
- should "do log to info if it's not running" do
42
- logger = mock("logger")
43
- logger.expects(:info)
44
- @env.stubs(:logger).returns(logger)
45
- @vm_for_real.stubs(:running?).returns(false)
46
- @foo_vm.expects(:provision).never
47
- @instance.execute(["foo"])
48
- end
49
-
50
- should "do log to info if it's not created" do
51
- logger = mock("logger")
52
- logger.expects(:info)
53
- @env.stubs(:logger).returns(logger)
54
- @foo_vm.stubs(:created?).returns(false)
55
- @foo_vm.expects(:provision).never
56
- @instance.execute(["foo"])
57
- end
58
- end
59
-
60
- end