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,78 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
-
3
- class BusyTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Busy
6
- end
7
-
8
- context "waiting for not busy" do
9
- setup do
10
- @klass.reset_trap_thread!
11
- end
12
-
13
- should "run in a thread" do
14
- Thread.expects(:new).once.returns(nil)
15
- @klass.wait_for_not_busy
16
- end
17
-
18
- should "immediately exit on second call" do
19
- tid = "foo"
20
- Thread.expects(:new).once.returns(tid)
21
- @klass.wait_for_not_busy
22
-
23
- Thread.expects(:kill).once.with(tid)
24
- @klass.expects(:abort).once
25
- @klass.wait_for_not_busy
26
- end
27
- end
28
-
29
- context "during an action in a busy block" do
30
- should "report as busy" do
31
- Vagrant.busy do
32
- # Inside the block Vagrant.busy? should be true
33
- assert Vagrant.busy?
34
- end
35
-
36
- #After the block finishes Vagrant.busy? should be false
37
- assert !Vagrant.busy?
38
- end
39
-
40
- should "set busy to false upon exception and reraise the error" do
41
- assert_raise Exception do
42
- Vagrant.busy do
43
- assert Vagrant.busy?
44
- raise Exception
45
- end
46
- end
47
-
48
- assert !Vagrant.busy?
49
- end
50
-
51
- should "complete the trap thread even if an exception occurs" do
52
- trap_thread = mock("trap_thread")
53
- trap_thread.expects(:join).once
54
- @klass.stubs(:trap_thread).returns(trap_thread)
55
-
56
- assert_raise Exception do
57
- Vagrant.busy do
58
- raise Exception
59
- end
60
- end
61
- end
62
-
63
- should "report busy to the outside world regardless of thread" do
64
- Thread.new do
65
- Vagrant.busy do
66
- assert Vagrant.busy?
67
- end
68
- end
69
- end
70
-
71
- should "trap INT" do
72
- trap_seq = sequence("trap_seq")
73
- Signal.expects(:trap).with("INT", anything).once.in_sequence(trap_seq)
74
- Signal.expects(:trap).with("INT", "DEFAULT").once.in_sequence(trap_seq)
75
- Vagrant.busy do; end
76
- end
77
- end
78
- end
@@ -1,53 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
-
3
- class CommandTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Command
6
- end
7
-
8
- context "initializing" do
9
- setup do
10
- @env = mock("environment")
11
- end
12
-
13
- should "set the env attribute" do
14
- @instance = @klass.new(@env)
15
- assert_equal @env, @instance.env
16
- end
17
- end
18
-
19
- context "class methods" do
20
- context "executing" do
21
- should "load the environment then send the command on commands" do
22
- env = mock("env")
23
- commands = mock("commands")
24
- env.stubs(:commands).returns(commands)
25
- Vagrant::Environment.expects(:load!).returns(env)
26
- commands.expects(:subcommand).with(1,2,3).once
27
-
28
- @klass.execute(1,2,3)
29
- end
30
- end
31
- end
32
-
33
- context "with an instance" do
34
- setup do
35
- @env = mock_environment
36
- @instance = @klass.new(@env)
37
- end
38
-
39
- context "subcommands" do
40
- setup do
41
- @raw_name = :bar
42
- @name = :foo
43
- @instance.stubs(:camelize).with(@raw_name).returns(@name)
44
- end
45
-
46
- should "send the env, name, and args to the base class" do
47
- args = [1,2,3]
48
- Vagrant::Commands::Base.expects(:dispatch).with(@env, @name, *args)
49
- @instance.subcommand(@name, *args)
50
- end
51
- end
52
- end
53
- end
@@ -1,139 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
-
3
- class CommandsBaseTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Commands::Base
6
- end
7
-
8
- context "initializing" do
9
- should "setup the env attribute" do
10
- env = mock("env")
11
- instance = @klass.new(env)
12
- assert_equal env, instance.env
13
- end
14
- end
15
-
16
- context "class methods" do
17
- setup do
18
- @env = mock_environment
19
- @klass.subcommands.clear
20
- end
21
-
22
- context "registering commands" do
23
- should "register commands" do
24
- klass = mock("klass")
25
- @klass.subcommand("init", klass)
26
- assert_equal klass, @klass.subcommands["init"]
27
- end
28
- end
29
-
30
- context "dispatching to subcommands" do
31
- setup do
32
- @command_klass = mock("klass")
33
- @name = "init"
34
- @klass.subcommand(@name, @command_klass)
35
-
36
- @args = [1,2,3]
37
- end
38
-
39
- should "call dispatch on child if subcommand is found" do
40
- @command_klass.expects(:dispatch).with(@env, *@args)
41
- @klass.dispatch(@env, @name, *@args)
42
- end
43
-
44
- should "instantiate and execute when no subcommand is found" do
45
- instance = mock("instance")
46
- @klass.expects(:new).with(@env).returns(instance)
47
- instance.expects(:execute).with(@args)
48
- @klass.dispatch(@env, *@args)
49
- end
50
- end
51
-
52
- context "descriptions" do
53
- should "be able to set description" do
54
- description = "The lazy fox yada yada"
55
- @klass.description(description)
56
- assert_equal description, @klass.description
57
- end
58
- end
59
- end
60
-
61
- context "instance methods" do
62
- setup do
63
- @env = mock_environment
64
- @instance = @klass.new(@env)
65
- end
66
-
67
- context "executing" do
68
- should "show version if flag is set" do
69
- @instance.expects(:puts_version).once
70
- @instance.expects(:show_help).never
71
- @instance.execute(["--version"])
72
- end
73
-
74
- should "just print the help by default" do
75
- @instance.expects(:puts_version).never
76
- @instance.expects(:show_help).once
77
- @instance.execute([])
78
- end
79
- end
80
-
81
- context "all or single methods" do
82
- should "call the single method if a name is given" do
83
- name = "bar"
84
- @instance.expects(:foo_single).with(name).once
85
- @instance.all_or_single(["bar"], :foo)
86
- end
87
-
88
- should "call the single method for each VM if no name is given" do
89
- vms = { :foo => nil, :bar => nil }
90
- vms.keys.each do |name|
91
- @instance.expects(:foo_single).with(name).once
92
- end
93
-
94
- @env.stubs(:vms).returns(vms)
95
- @instance.all_or_single([], :foo)
96
- end
97
- end
98
-
99
- context "getting the option parser" do
100
- should "create it with the options spec if it hasn't been created yet" do
101
- opts = mock("opts")
102
- opts.stubs(:on)
103
-
104
- result = mock("result")
105
- OptionParser.expects(:new).yields(opts).returns(result)
106
- @instance.expects(:options_spec).with(opts)
107
-
108
- assert_equal result, @instance.option_parser(true)
109
- end
110
-
111
- should "not create it once its been created" do
112
- result = mock("result")
113
- OptionParser.expects(:new).once.returns(result)
114
-
115
- assert_equal result, @instance.option_parser(true)
116
- assert_equal result, @instance.option_parser
117
- assert_equal result, @instance.option_parser
118
- end
119
- end
120
-
121
- context "parsing options" do
122
- setup do
123
- @args = []
124
-
125
- @options = mock("options")
126
- @option_parser = mock("option_parser")
127
-
128
- @instance.stubs(:option_parser).returns(@option_parser)
129
- @instance.stubs(:options).returns(@options)
130
- end
131
-
132
- should "parse the options with the args" do
133
- result = mock("result")
134
- @option_parser.expects(:parse!).with(@args).once.returns(result)
135
- assert_equal result, @instance.parse_options(@args)
136
- end
137
- end
138
- end
139
- end
@@ -1,34 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', '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 File.join(File.dirname(__FILE__), '..', '..', '..', '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 File.join(File.dirname(__FILE__), '..', '..', '..', '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,44 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '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 File.join(File.dirname(__FILE__), '..', '..', '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