vagrantup 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/vagrant +5 -13
- data/config/default.rb +1 -0
- data/keys/README.md +8 -1
- data/keys/vagrant.ppk +26 -0
- data/lib/vagrant.rb +3 -3
- data/lib/vagrant/actions/base.rb +15 -4
- data/lib/vagrant/actions/box/add.rb +1 -1
- data/lib/vagrant/actions/box/download.rb +72 -66
- data/lib/vagrant/actions/box/unpackage.rb +1 -4
- data/lib/vagrant/actions/runner.rb +1 -1
- data/lib/vagrant/actions/vm/boot.rb +5 -7
- data/lib/vagrant/actions/vm/customize.rb +2 -2
- data/lib/vagrant/actions/vm/destroy.rb +2 -2
- data/lib/vagrant/actions/vm/down.rb +7 -0
- data/lib/vagrant/actions/vm/export.rb +10 -4
- data/lib/vagrant/actions/vm/forward_ports.rb +5 -15
- data/lib/vagrant/actions/vm/halt.rb +5 -3
- data/lib/vagrant/actions/vm/import.rb +10 -3
- data/lib/vagrant/actions/vm/move_hard_drive.rb +1 -3
- data/lib/vagrant/actions/vm/package.rb +33 -10
- data/lib/vagrant/actions/vm/provision.rb +4 -4
- data/lib/vagrant/actions/vm/reload.rb +1 -1
- data/lib/vagrant/actions/vm/resume.rb +1 -1
- data/lib/vagrant/actions/vm/shared_folders.rb +7 -7
- data/lib/vagrant/actions/vm/start.rb +3 -2
- data/lib/vagrant/actions/vm/suspend.rb +2 -2
- data/lib/vagrant/actions/vm/up.rb +7 -17
- data/lib/vagrant/active_list.rb +52 -45
- data/lib/vagrant/box.rb +18 -11
- data/lib/vagrant/busy.rb +7 -0
- data/lib/vagrant/command.rb +27 -0
- data/lib/vagrant/commands/base.rb +163 -0
- data/lib/vagrant/commands/box.rb +16 -0
- data/lib/vagrant/commands/box/add.rb +24 -0
- data/lib/vagrant/commands/box/list.rb +30 -0
- data/lib/vagrant/commands/box/remove.rb +31 -0
- data/lib/vagrant/commands/destroy.rb +23 -0
- data/lib/vagrant/commands/down.rb +16 -0
- data/lib/vagrant/commands/halt.rb +23 -0
- data/lib/vagrant/commands/init.rb +32 -0
- data/lib/vagrant/commands/package.rb +46 -0
- data/lib/vagrant/commands/reload.rb +22 -0
- data/lib/vagrant/commands/resume.rb +22 -0
- data/lib/vagrant/commands/ssh.rb +22 -0
- data/lib/vagrant/commands/ssh_config.rb +30 -0
- data/lib/vagrant/commands/status.rb +58 -0
- data/lib/vagrant/commands/suspend.rb +23 -0
- data/lib/vagrant/commands/up.rb +26 -0
- data/lib/vagrant/config.rb +21 -11
- data/lib/vagrant/downloaders/file.rb +5 -5
- data/lib/vagrant/downloaders/http.rb +10 -15
- data/lib/vagrant/environment.rb +259 -0
- data/lib/vagrant/provisioners/base.rb +7 -0
- data/lib/vagrant/provisioners/chef.rb +24 -9
- data/lib/vagrant/provisioners/chef_server.rb +23 -48
- data/lib/vagrant/provisioners/chef_solo.rb +48 -22
- data/lib/vagrant/ssh.rb +95 -46
- data/lib/vagrant/util.rb +2 -2
- data/lib/vagrant/util/errors.rb +36 -0
- data/lib/vagrant/util/platform.rb +12 -0
- data/lib/vagrant/util/progress_meter.rb +33 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/vm.rb +1 -0
- data/templates/{Vagrantfile → Vagrantfile.erb} +2 -2
- data/templates/chef_server_client.erb +16 -0
- data/templates/chef_solo_solo.erb +4 -0
- data/templates/errors.yml +157 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/ssh_config.erb +7 -0
- data/test/test_helper.rb +12 -15
- data/test/vagrant/actions/box/add_test.rb +1 -2
- data/test/vagrant/actions/box/destroy_test.rb +0 -1
- data/test/vagrant/actions/box/download_test.rb +40 -15
- data/test/vagrant/actions/box/unpackage_test.rb +2 -3
- data/test/vagrant/actions/collection_test.rb +8 -5
- data/test/vagrant/actions/runner_test.rb +8 -6
- data/test/vagrant/actions/vm/boot_test.rb +12 -11
- data/test/vagrant/actions/vm/customize_test.rb +2 -3
- data/test/vagrant/actions/vm/destroy_test.rb +2 -3
- data/test/vagrant/actions/vm/down_test.rb +16 -3
- data/test/vagrant/actions/vm/export_test.rb +4 -5
- data/test/vagrant/actions/vm/forward_ports_test.rb +6 -5
- data/test/vagrant/actions/vm/halt_test.rb +8 -2
- data/test/vagrant/actions/vm/import_test.rb +5 -5
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +4 -6
- data/test/vagrant/actions/vm/package_test.rb +60 -22
- data/test/vagrant/actions/vm/provision_test.rb +7 -16
- data/test/vagrant/actions/vm/reload_test.rb +3 -2
- data/test/vagrant/actions/vm/resume_test.rb +0 -1
- data/test/vagrant/actions/vm/shared_folders_test.rb +17 -12
- data/test/vagrant/actions/vm/start_test.rb +10 -3
- data/test/vagrant/actions/vm/suspend_test.rb +1 -2
- data/test/vagrant/actions/vm/up_test.rb +19 -11
- data/test/vagrant/active_list_test.rb +148 -129
- data/test/vagrant/box_test.rb +26 -14
- data/test/vagrant/busy_test.rb +15 -6
- data/test/vagrant/command_test.rb +53 -0
- data/test/vagrant/commands/base_test.rb +118 -0
- data/test/vagrant/commands/box/add_test.rb +34 -0
- data/test/vagrant/commands/box/list_test.rb +32 -0
- data/test/vagrant/commands/box/remove_test.rb +41 -0
- data/test/vagrant/commands/destroy_test.rb +32 -0
- data/test/vagrant/commands/down_test.rb +17 -0
- data/test/vagrant/commands/halt_test.rb +28 -0
- data/test/vagrant/commands/init_test.rb +55 -0
- data/test/vagrant/commands/package_test.rb +84 -0
- data/test/vagrant/commands/reload_test.rb +28 -0
- data/test/vagrant/commands/resume_test.rb +33 -0
- data/test/vagrant/commands/ssh_config_test.rb +54 -0
- data/test/vagrant/commands/ssh_test.rb +32 -0
- data/test/vagrant/commands/status_test.rb +20 -0
- data/test/vagrant/commands/suspend_test.rb +33 -0
- data/test/vagrant/commands/up_test.rb +41 -0
- data/test/vagrant/config_test.rb +42 -17
- data/test/vagrant/downloaders/file_test.rb +7 -0
- data/test/vagrant/downloaders/http_test.rb +12 -0
- data/test/vagrant/environment_test.rb +595 -0
- data/test/vagrant/provisioners/base_test.rb +7 -1
- data/test/vagrant/provisioners/chef_server_test.rb +41 -51
- data/test/vagrant/provisioners/chef_solo_test.rb +93 -62
- data/test/vagrant/provisioners/chef_test.rb +61 -15
- data/test/vagrant/ssh_test.rb +166 -38
- data/test/vagrant/util/errors_test.rb +57 -0
- data/test/vagrant/util/progress_meter_test.rb +33 -0
- data/test/vagrant/{stacked_proc_runner_test.rb → util/stacked_proc_runner_test.rb} +3 -3
- data/test/vagrant/util/template_renderer_test.rb +138 -0
- data/test/vagrant/vm_test.rb +3 -2
- data/vagrant.gemspec +88 -33
- metadata +92 -49
- data/bin/vagrant-box +0 -34
- data/bin/vagrant-down +0 -27
- data/bin/vagrant-halt +0 -28
- data/bin/vagrant-init +0 -27
- data/bin/vagrant-package +0 -29
- data/bin/vagrant-reload +0 -29
- data/bin/vagrant-resume +0 -27
- data/bin/vagrant-ssh +0 -27
- data/bin/vagrant-status +0 -29
- data/bin/vagrant-suspend +0 -27
- data/bin/vagrant-up +0 -29
- data/lib/vagrant/commands.rb +0 -234
- data/lib/vagrant/env.rb +0 -189
- data/lib/vagrant/stacked_proc_runner.rb +0 -33
- data/test/vagrant/commands_test.rb +0 -269
- data/test/vagrant/env_test.rb +0 -418
data/test/vagrant/box_test.rb
CHANGED
@@ -2,36 +2,40 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
2
2
|
|
3
3
|
class BoxTest < Test::Unit::TestCase
|
4
4
|
context "class methods" do
|
5
|
+
setup do
|
6
|
+
@env = mock_environment
|
7
|
+
end
|
8
|
+
|
5
9
|
context "listing all boxes" do
|
6
10
|
setup do
|
7
11
|
Dir.stubs(:open)
|
8
12
|
File.stubs(:directory?).returns(true)
|
9
13
|
|
10
14
|
@boxes_path = "foo"
|
11
|
-
|
15
|
+
@env.stubs(:boxes_path).returns(@boxes_path)
|
12
16
|
end
|
13
17
|
|
14
18
|
should "open the boxes directory" do
|
15
|
-
Dir.expects(:open).with(
|
16
|
-
Vagrant::Box.all
|
19
|
+
Dir.expects(:open).with(@env.boxes_path)
|
20
|
+
Vagrant::Box.all(@env)
|
17
21
|
end
|
18
22
|
|
19
23
|
should "return an array" do
|
20
|
-
result = Vagrant::Box.all
|
24
|
+
result = Vagrant::Box.all(@env)
|
21
25
|
assert result.is_a?(Array)
|
22
26
|
end
|
23
27
|
|
24
28
|
should "not return the '.' and '..' directories" do
|
25
29
|
dir = [".", "..", "..", ".", ".."]
|
26
30
|
Dir.expects(:open).yields(dir)
|
27
|
-
result = Vagrant::Box.all
|
31
|
+
result = Vagrant::Box.all(@env)
|
28
32
|
assert result.empty?
|
29
33
|
end
|
30
34
|
|
31
35
|
should "return the other directories" do
|
32
36
|
dir = [".", "foo", "bar", "baz"]
|
33
37
|
Dir.expects(:open).yields(dir)
|
34
|
-
result = Vagrant::Box.all
|
38
|
+
result = Vagrant::Box.all(@env)
|
35
39
|
assert_equal ["foo", "bar", "baz"], result
|
36
40
|
end
|
37
41
|
|
@@ -44,7 +48,7 @@ class BoxTest < Test::Unit::TestCase
|
|
44
48
|
File.expects(:directory?).with(File.join(@boxes_path, dir)).returns(files[index]).in_sequence(dir_sequence)
|
45
49
|
end
|
46
50
|
|
47
|
-
result = Vagrant::Box.all
|
51
|
+
result = Vagrant::Box.all(@env)
|
48
52
|
assert_equal ["foo"], result
|
49
53
|
end
|
50
54
|
end
|
@@ -53,20 +57,27 @@ class BoxTest < Test::Unit::TestCase
|
|
53
57
|
setup do
|
54
58
|
@dir = "foo"
|
55
59
|
@name = "bar"
|
56
|
-
Vagrant::Box.stubs(:directory).with(@name).returns(@dir)
|
60
|
+
Vagrant::Box.stubs(:directory).with(@env, @name).returns(@dir)
|
57
61
|
end
|
58
62
|
|
59
63
|
should "return nil if the box doesn't exist" do
|
60
64
|
File.expects(:directory?).with(@dir).once.returns(false)
|
61
|
-
assert_nil Vagrant::Box.find(@name)
|
65
|
+
assert_nil Vagrant::Box.find(@env, @name)
|
62
66
|
end
|
63
67
|
|
64
68
|
should "return a box object with the proper name set" do
|
65
69
|
File.expects(:directory?).with(@dir).once.returns(true)
|
66
|
-
result = Vagrant::Box.find(@name)
|
70
|
+
result = Vagrant::Box.find(@env, @name)
|
67
71
|
assert result
|
68
72
|
assert_equal @name, result.name
|
69
73
|
end
|
74
|
+
|
75
|
+
should "return a box object with the proper env set" do
|
76
|
+
File.expects(:directory?).with(@dir).once.returns(true)
|
77
|
+
result = Vagrant::Box.find(@env, @name)
|
78
|
+
assert result
|
79
|
+
assert_equal @env, result.env
|
80
|
+
end
|
70
81
|
end
|
71
82
|
|
72
83
|
context "adding" do
|
@@ -79,20 +90,21 @@ class BoxTest < Test::Unit::TestCase
|
|
79
90
|
box = mock("box")
|
80
91
|
box.expects(:name=).with(@name)
|
81
92
|
box.expects(:uri=).with(@uri)
|
93
|
+
box.expects(:env=).with(@env)
|
82
94
|
box.expects(:add).once
|
83
95
|
Vagrant::Box.expects(:new).returns(box)
|
84
|
-
Vagrant::Box.add(@name, @uri)
|
96
|
+
Vagrant::Box.add(@env, @name, @uri)
|
85
97
|
end
|
86
98
|
end
|
87
99
|
|
88
100
|
context "box directory" do
|
89
101
|
setup do
|
90
102
|
@name = "foo"
|
91
|
-
@box_dir = File.join(
|
103
|
+
@box_dir = File.join(@env.boxes_path, @name)
|
92
104
|
end
|
93
105
|
|
94
106
|
should "return the boxes_path joined with the name" do
|
95
|
-
assert_equal @box_dir, Vagrant::Box.directory(@name)
|
107
|
+
assert_equal @box_dir, Vagrant::Box.directory(@env, @name)
|
96
108
|
end
|
97
109
|
end
|
98
110
|
end
|
@@ -114,7 +126,7 @@ class BoxTest < Test::Unit::TestCase
|
|
114
126
|
|
115
127
|
should "return the boxes_path joined with the name" do
|
116
128
|
result = mock("object")
|
117
|
-
Vagrant::Box.expects(:directory).with(@box.name).returns(result)
|
129
|
+
Vagrant::Box.expects(:directory).with(@box.env, @box.name).returns(result)
|
118
130
|
assert result.equal?(@box.directory)
|
119
131
|
end
|
120
132
|
end
|
data/test/vagrant/busy_test.rb
CHANGED
@@ -1,19 +1,28 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
2
|
|
3
3
|
class BusyTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Busy
|
6
|
+
end
|
7
|
+
|
4
8
|
context "waiting for not busy" do
|
5
9
|
setup do
|
6
|
-
|
10
|
+
@klass.reset_trap_thread!
|
7
11
|
end
|
8
12
|
|
9
13
|
should "run in a thread" do
|
10
14
|
Thread.expects(:new).once.returns(nil)
|
11
|
-
|
15
|
+
@klass.wait_for_not_busy
|
12
16
|
end
|
13
17
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
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
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
@@ -42,7 +51,7 @@ class BusyTest < Test::Unit::TestCase
|
|
42
51
|
should "complete the trap thread even if an exception occurs" do
|
43
52
|
trap_thread = mock("trap_thread")
|
44
53
|
trap_thread.expects(:join).once
|
45
|
-
|
54
|
+
@klass.stubs(:trap_thread).returns(trap_thread)
|
46
55
|
|
47
56
|
assert_raise Exception do
|
48
57
|
Vagrant.busy do
|
@@ -0,0 +1,53 @@
|
|
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
|
@@ -0,0 +1,118 @@
|
|
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(:puts_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
|
+
@klass.expects(:puts_help)
|
77
|
+
@instance.execute([])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "getting the option parser" do
|
82
|
+
should "create it with the options spec if it hasn't been created yet" do
|
83
|
+
opts = mock("opts")
|
84
|
+
result = mock("result")
|
85
|
+
OptionParser.expects(:new).yields(opts).returns(result)
|
86
|
+
@instance.expects(:options_spec).with(opts)
|
87
|
+
|
88
|
+
assert_equal result, @instance.option_parser(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
should "not create it once its been created" do
|
92
|
+
result = mock("result")
|
93
|
+
OptionParser.expects(:new).once.returns(result)
|
94
|
+
|
95
|
+
assert_equal result, @instance.option_parser(true)
|
96
|
+
assert_equal result, @instance.option_parser
|
97
|
+
assert_equal result, @instance.option_parser
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "parsing options" do
|
102
|
+
setup do
|
103
|
+
@args = []
|
104
|
+
|
105
|
+
@options = mock("options")
|
106
|
+
@option_parser = mock("option_parser")
|
107
|
+
|
108
|
+
@instance.stubs(:option_parser).returns(@option_parser)
|
109
|
+
@instance.stubs(:options).returns(@options)
|
110
|
+
end
|
111
|
+
|
112
|
+
should "parse the options with the args" do
|
113
|
+
@option_parser.expects(:parse!).with(@args).once
|
114
|
+
assert_equal @options, @instance.parse_options(@args)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,32 @@
|
|
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
|
@@ -0,0 +1,41 @@
|
|
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
|