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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/config/default.rb +6 -6
- data/lib/vagrant.rb +6 -3
- data/lib/vagrant/action.rb +77 -0
- data/lib/vagrant/action/action_exception.rb +16 -0
- data/lib/vagrant/action/box/destroy.rb +19 -0
- data/lib/vagrant/action/box/download.rb +78 -0
- data/lib/vagrant/action/box/unpackage.rb +58 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +151 -0
- data/lib/vagrant/action/builtin.rb +114 -0
- data/lib/vagrant/action/env/error_halt.rb +16 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +98 -0
- data/lib/vagrant/action/exception_catcher.rb +14 -0
- data/lib/vagrant/action/vm/boot.rb +54 -0
- data/lib/vagrant/action/vm/check_box.rb +27 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +20 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
- data/lib/vagrant/action/vm/disable_networks.rb +26 -0
- data/lib/vagrant/action/vm/export.rb +53 -0
- data/lib/vagrant/action/vm/forward_ports.rb +121 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +34 -0
- data/lib/vagrant/action/vm/import.rb +33 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
- data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
- data/lib/vagrant/action/vm/nfs.rb +161 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +99 -0
- data/lib/vagrant/action/vm/persist.rb +22 -0
- data/lib/vagrant/action/vm/provision.rb +50 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/box.rb +3 -7
- data/lib/vagrant/commands/base.rb +1 -3
- data/lib/vagrant/commands/package.rb +4 -9
- data/lib/vagrant/commands/up.rb +0 -2
- data/lib/vagrant/config.rb +15 -1
- data/lib/vagrant/downloaders/file.rb +1 -1
- data/lib/vagrant/downloaders/http.rb +2 -1
- data/lib/vagrant/environment.rb +18 -14
- data/lib/vagrant/hosts/base.rb +77 -0
- data/lib/vagrant/hosts/bsd.rb +53 -0
- data/lib/vagrant/hosts/linux.rb +52 -0
- data/lib/vagrant/provisioners/base.rb +17 -9
- data/lib/vagrant/provisioners/chef.rb +1 -1
- data/lib/vagrant/provisioners/chef_server.rb +4 -8
- data/lib/vagrant/provisioners/chef_solo.rb +1 -2
- data/lib/vagrant/ssh.rb +12 -4
- data/lib/vagrant/systems/base.rb +4 -0
- data/lib/vagrant/systems/linux.rb +12 -1
- data/lib/vagrant/util.rb +16 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/plain_logger.rb +11 -0
- data/lib/vagrant/util/platform.rb +18 -0
- data/lib/vagrant/util/resource_logger.rb +128 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +10 -12
- data/templates/chef_solo_solo.erb +2 -1
- data/templates/nfs/exports.erb +3 -0
- data/templates/nfs/exports_linux.erb +3 -0
- data/templates/strings.yml +23 -3
- metadata +121 -196
- data/.gitignore +0 -11
- data/Gemfile +0 -18
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/bin/.gitignore +0 -0
- data/lib/vagrant/actions/base.rb +0 -130
- data/lib/vagrant/actions/box/add.rb +0 -23
- data/lib/vagrant/actions/box/destroy.rb +0 -14
- data/lib/vagrant/actions/box/download.rb +0 -67
- data/lib/vagrant/actions/box/unpackage.rb +0 -42
- data/lib/vagrant/actions/box/verify.rb +0 -32
- data/lib/vagrant/actions/collection.rb +0 -36
- data/lib/vagrant/actions/runner.rb +0 -131
- data/lib/vagrant/actions/vm/boot.rb +0 -43
- data/lib/vagrant/actions/vm/customize.rb +0 -19
- data/lib/vagrant/actions/vm/destroy.rb +0 -24
- data/lib/vagrant/actions/vm/down.rb +0 -22
- data/lib/vagrant/actions/vm/export.rb +0 -45
- data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
- data/lib/vagrant/actions/vm/halt.rb +0 -24
- data/lib/vagrant/actions/vm/import.rb +0 -23
- data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
- data/lib/vagrant/actions/vm/package.rb +0 -94
- data/lib/vagrant/actions/vm/provision.rb +0 -49
- data/lib/vagrant/actions/vm/reload.rb +0 -17
- data/lib/vagrant/actions/vm/resume.rb +0 -16
- data/lib/vagrant/actions/vm/start.rb +0 -26
- data/lib/vagrant/actions/vm/suspend.rb +0 -16
- data/lib/vagrant/actions/vm/up.rb +0 -53
- data/lib/vagrant/busy.rb +0 -79
- data/lib/vagrant/resource_logger.rb +0 -126
- data/lib/vagrant/util/error_helper.rb +0 -13
- data/lib/vagrant/util/output_helper.rb +0 -9
- data/test/test_helper.rb +0 -149
- data/test/vagrant/actions/base_test.rb +0 -32
- data/test/vagrant/actions/box/add_test.rb +0 -36
- data/test/vagrant/actions/box/destroy_test.rb +0 -17
- data/test/vagrant/actions/box/download_test.rb +0 -137
- data/test/vagrant/actions/box/unpackage_test.rb +0 -99
- data/test/vagrant/actions/box/verify_test.rb +0 -44
- data/test/vagrant/actions/collection_test.rb +0 -113
- data/test/vagrant/actions/runner_test.rb +0 -268
- data/test/vagrant/actions/vm/boot_test.rb +0 -49
- data/test/vagrant/actions/vm/customize_test.rb +0 -21
- data/test/vagrant/actions/vm/destroy_test.rb +0 -37
- data/test/vagrant/actions/vm/down_test.rb +0 -39
- data/test/vagrant/actions/vm/export_test.rb +0 -88
- data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
- data/test/vagrant/actions/vm/halt_test.rb +0 -65
- data/test/vagrant/actions/vm/import_test.rb +0 -45
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
- data/test/vagrant/actions/vm/network_test.rb +0 -291
- data/test/vagrant/actions/vm/package_test.rb +0 -254
- data/test/vagrant/actions/vm/provision_test.rb +0 -99
- data/test/vagrant/actions/vm/reload_test.rb +0 -46
- data/test/vagrant/actions/vm/resume_test.rb +0 -26
- data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
- data/test/vagrant/actions/vm/start_test.rb +0 -73
- data/test/vagrant/actions/vm/suspend_test.rb +0 -26
- data/test/vagrant/actions/vm/up_test.rb +0 -96
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/box_test.rb +0 -154
- data/test/vagrant/busy_test.rb +0 -78
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -55
- data/test/vagrant/commands/package_test.rb +0 -104
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -44
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -47
- data/test/vagrant/config_test.rb +0 -287
- data/test/vagrant/downloaders/base_test.rb +0 -28
- data/test/vagrant/downloaders/file_test.rb +0 -33
- data/test/vagrant/downloaders/http_test.rb +0 -62
- data/test/vagrant/environment_test.rb +0 -770
- data/test/vagrant/provisioners/base_test.rb +0 -33
- data/test/vagrant/provisioners/chef_server_test.rb +0 -176
- data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
- data/test/vagrant/provisioners/chef_test.rb +0 -175
- data/test/vagrant/resource_logger_test.rb +0 -145
- data/test/vagrant/ssh_session_test.rb +0 -46
- data/test/vagrant/ssh_test.rb +0 -296
- data/test/vagrant/systems/linux_test.rb +0 -179
- data/test/vagrant/util/error_helper_test.rb +0 -5
- data/test/vagrant/util/output_helper_test.rb +0 -5
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/platform_test.rb +0 -18
- data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/vagrant/util/template_renderer_test.rb +0 -144
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
- data/test/vagrant/vm_test.rb +0 -235
- data/vagrant.gemspec +0 -291
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class SuspendActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Suspend)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "executing" do
|
9
|
-
setup do
|
10
|
-
@vm.stubs(:running?).returns(true)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "save the state of the VM" do
|
14
|
-
@vm.expects(:save_state).once
|
15
|
-
@action.execute!
|
16
|
-
end
|
17
|
-
|
18
|
-
should "raise an ActionException if the VM is not running" do
|
19
|
-
@vm.expects(:running?).returns(false)
|
20
|
-
@vm.expects(:save_state).never
|
21
|
-
assert_raises(Vagrant::Actions::ActionException) {
|
22
|
-
@action.execute!
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class UpActionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Up)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "sub-actions" do
|
9
|
-
setup do
|
10
|
-
@runner.stubs(:created?).returns(false)
|
11
|
-
|
12
|
-
File.stubs(:file?).returns(true)
|
13
|
-
File.stubs(:exist?).returns(true)
|
14
|
-
@default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Start]
|
15
|
-
|
16
|
-
@dotfile_path = "foo"
|
17
|
-
@runner.env.stubs(:dotfile_path).returns(@dotfile_path)
|
18
|
-
end
|
19
|
-
|
20
|
-
def setup_action_expectations
|
21
|
-
default_seq = sequence("default_seq")
|
22
|
-
@default_order.each do |action|
|
23
|
-
@runner.expects(:add_action).with(action, @action.options).once.in_sequence(default_seq)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
should "raise an ActionException if a dotfile exists but is not a file" do
|
28
|
-
File.expects(:file?).with(@runner.env.dotfile_path).returns(false)
|
29
|
-
assert_raises(Vagrant::Actions::ActionException) {
|
30
|
-
@action.prepare
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
should "not raise an ActionException if dotfile doesn't exist" do
|
35
|
-
setup_action_expectations
|
36
|
-
File.stubs(:exist?).returns(false)
|
37
|
-
assert_nothing_raised { @action.prepare }
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not raise an ActionException if dotfile exists but is a file" do
|
41
|
-
File.stubs(:file?).returns(true)
|
42
|
-
File.stubs(:exist?).returns(true)
|
43
|
-
setup_action_expectations
|
44
|
-
assert_nothing_raised { @action.prepare }
|
45
|
-
end
|
46
|
-
|
47
|
-
should "do the proper actions by default" do
|
48
|
-
setup_action_expectations
|
49
|
-
@action.prepare
|
50
|
-
end
|
51
|
-
|
52
|
-
should "add in the action to move hard drive if config is set" do
|
53
|
-
env = mock_environment do |config|
|
54
|
-
File.expects(:directory?).with("foo").returns(true)
|
55
|
-
config.vm.hd_location = "foo"
|
56
|
-
end
|
57
|
-
|
58
|
-
@runner.stubs(:env).returns(env)
|
59
|
-
env.stubs(:dotfile_path).returns(@dotfile_path)
|
60
|
-
|
61
|
-
@default_order.insert(0, Vagrant::Actions::VM::MoveHardDrive)
|
62
|
-
setup_action_expectations
|
63
|
-
@action.prepare
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "callbacks" do
|
68
|
-
should "call update dotfile and mac address setup after import" do
|
69
|
-
boot_seq = sequence("boot")
|
70
|
-
@action.expects(:update_dotfile).once.in_sequence(boot_seq)
|
71
|
-
@action.expects(:setup_mac_address).once.in_sequence(boot_seq)
|
72
|
-
@action.expects(:check_guest_additions).once.in_sequence(boot_seq)
|
73
|
-
@action.after_import
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "updating the dotfile" do
|
78
|
-
should "call update dotfile on the VM's environment" do
|
79
|
-
@runner.stubs(:uuid)
|
80
|
-
@runner.env.expects(:update_dotfile).once
|
81
|
-
@action.update_dotfile
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "setting up MAC address" do
|
86
|
-
should "match the mac address with the base" do
|
87
|
-
nic = mock("nic")
|
88
|
-
nic.expects(:mac_address=).once
|
89
|
-
|
90
|
-
@vm.expects(:network_adapters).returns([nic]).once
|
91
|
-
@vm.expects(:save).once
|
92
|
-
|
93
|
-
@action.setup_mac_address
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,173 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
-
|
3
|
-
class ActiveListTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@env = mock_environment
|
6
|
-
@list = Vagrant::ActiveList.new(@env)
|
7
|
-
end
|
8
|
-
|
9
|
-
context "initializing" do
|
10
|
-
should "set the environment to nil if not specified" do
|
11
|
-
assert_nothing_raised {
|
12
|
-
list = Vagrant::ActiveList.new
|
13
|
-
assert list.env.nil?
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
should "set the environment to the given parameter if specified" do
|
18
|
-
env = mock("env")
|
19
|
-
list = Vagrant::ActiveList.new(env)
|
20
|
-
assert_equal env, list.env
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "listing" do
|
25
|
-
setup do
|
26
|
-
@path = "foo"
|
27
|
-
@list.stubs(:path).returns(@path)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "load if reload is given" do
|
31
|
-
File.stubs(:file?).returns(true)
|
32
|
-
File.expects(:open).once
|
33
|
-
@list.list(true)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "not load if the active json file doesn't exist" do
|
37
|
-
File.expects(:file?).with(@list.path).returns(false)
|
38
|
-
File.expects(:open).never
|
39
|
-
assert_equal Hash.new, @list.list(true)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "parse the JSON by reading the file" do
|
43
|
-
file = mock("file")
|
44
|
-
data = mock("data")
|
45
|
-
result = { :hey => :yep }
|
46
|
-
File.expects(:file?).returns(true)
|
47
|
-
File.expects(:open).with(@list.path, 'r').once.yields(file)
|
48
|
-
file.expects(:read).returns(data)
|
49
|
-
JSON.expects(:parse).with(data).returns(result)
|
50
|
-
assert_equal result, @list.list(true)
|
51
|
-
end
|
52
|
-
|
53
|
-
should "not load if reload flag is false and already loaded" do
|
54
|
-
File.expects(:file?).once.returns(false)
|
55
|
-
result = @list.list(true)
|
56
|
-
assert result.equal?(@list.list)
|
57
|
-
assert result.equal?(@list.list)
|
58
|
-
assert result.equal?(@list.list)
|
59
|
-
end
|
60
|
-
|
61
|
-
should "be an empty hash if JSON parsing raises an exception" do
|
62
|
-
file = mock("file")
|
63
|
-
file.stubs(:read)
|
64
|
-
File.expects(:file?).returns(true)
|
65
|
-
File.expects(:open).with(@list.path, 'r').once.yields(file)
|
66
|
-
JSON.expects(:parse).raises(Exception)
|
67
|
-
|
68
|
-
assert_nothing_raised do
|
69
|
-
assert_equal Hash.new, @list.list(true)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "filter list" do
|
75
|
-
should "remove nonexistent VMs" do
|
76
|
-
list = {}
|
77
|
-
result = {}
|
78
|
-
5.times do |i|
|
79
|
-
vm = mock("vm#{i}")
|
80
|
-
vm.stubs(:uuid).returns(i)
|
81
|
-
|
82
|
-
list[vm.uuid] = {}
|
83
|
-
|
84
|
-
found_vm = i % 2 ? nil : vm
|
85
|
-
Vagrant::VM.stubs(:find).with(vm.uuid, @env).returns(found_vm)
|
86
|
-
results[vm.uuid] = {} if found_vm
|
87
|
-
end
|
88
|
-
|
89
|
-
@list.stubs(:list).returns(list)
|
90
|
-
assert_equal result, @list.filter_list
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "adding a VM to the list" do
|
95
|
-
setup do
|
96
|
-
@the_list = {}
|
97
|
-
@list.stubs(:list).returns(@the_list)
|
98
|
-
@list.stubs(:save)
|
99
|
-
|
100
|
-
@uuid = "foo"
|
101
|
-
@vm = mock("vm")
|
102
|
-
@vm.stubs(:uuid).returns(@uuid)
|
103
|
-
end
|
104
|
-
|
105
|
-
should "add the VMs UUID to the list" do
|
106
|
-
@list.add(@vm)
|
107
|
-
assert @the_list[@uuid]
|
108
|
-
assert @the_list[@uuid].is_a?(Hash)
|
109
|
-
end
|
110
|
-
|
111
|
-
should "save after adding" do
|
112
|
-
save_seq = sequence('save')
|
113
|
-
@the_list.expects(:[]=).in_sequence(save_seq)
|
114
|
-
@list.expects(:save).in_sequence(save_seq)
|
115
|
-
@list.add(@vm)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "deleting a VM from the list" do
|
120
|
-
setup do
|
121
|
-
@the_list = ["bar"]
|
122
|
-
@list.stubs(:list).returns(@the_list)
|
123
|
-
@list.stubs(:save)
|
124
|
-
|
125
|
-
@uuid = "bar"
|
126
|
-
@vm = mock("vm")
|
127
|
-
@vm.stubs(:uuid).returns(@uuid)
|
128
|
-
@vm.stubs(:is_a?).with(Vagrant::VM).returns(true)
|
129
|
-
end
|
130
|
-
|
131
|
-
should "delete the uuid from the list of a VM" do
|
132
|
-
@list.remove(@vm)
|
133
|
-
assert @the_list.empty?
|
134
|
-
end
|
135
|
-
|
136
|
-
should "delete just the string if a string is given" do
|
137
|
-
@the_list << "zoo"
|
138
|
-
@list.remove("zoo")
|
139
|
-
assert !@the_list.include?("zoo")
|
140
|
-
end
|
141
|
-
|
142
|
-
should "save after removing" do
|
143
|
-
save_seq = sequence('save')
|
144
|
-
@the_list.expects(:delete).in_sequence(save_seq)
|
145
|
-
@list.expects(:save).in_sequence(save_seq)
|
146
|
-
@list.remove(@vm)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "saving" do
|
151
|
-
setup do
|
152
|
-
@filtered = ["zoo"]
|
153
|
-
@list.stubs(:filter_list).returns(@filtered)
|
154
|
-
end
|
155
|
-
|
156
|
-
should "open the JSON path and save to it" do
|
157
|
-
file = mock("file")
|
158
|
-
File.expects(:open).with(@list.path, "w+").yields(file)
|
159
|
-
file.expects(:write).with(@filtered.to_json)
|
160
|
-
@list.save
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context "path" do
|
165
|
-
setup do
|
166
|
-
@env.stubs(:home_path).returns("foo")
|
167
|
-
end
|
168
|
-
|
169
|
-
should "return the active file within the home path" do
|
170
|
-
assert_equal File.join(@env.home_path, Vagrant::ActiveList::FILENAME), @list.path
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
data/test/vagrant/box_test.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
-
|
3
|
-
class BoxTest < Test::Unit::TestCase
|
4
|
-
context "class methods" do
|
5
|
-
setup do
|
6
|
-
@env = mock_environment
|
7
|
-
end
|
8
|
-
|
9
|
-
context "listing all boxes" do
|
10
|
-
setup do
|
11
|
-
Dir.stubs(:open)
|
12
|
-
File.stubs(:directory?).returns(true)
|
13
|
-
|
14
|
-
@boxes_path = "foo"
|
15
|
-
@env.stubs(:boxes_path).returns(@boxes_path)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "open the boxes directory" do
|
19
|
-
Dir.expects(:open).with(@env.boxes_path)
|
20
|
-
Vagrant::Box.all(@env)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "return an array" do
|
24
|
-
result = Vagrant::Box.all(@env)
|
25
|
-
assert result.is_a?(Array)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "not return the '.' and '..' directories" do
|
29
|
-
dir = [".", "..", "..", ".", ".."]
|
30
|
-
Dir.expects(:open).yields(dir)
|
31
|
-
result = Vagrant::Box.all(@env)
|
32
|
-
assert result.empty?
|
33
|
-
end
|
34
|
-
|
35
|
-
should "return the other directories" do
|
36
|
-
dir = [".", "foo", "bar", "baz"]
|
37
|
-
Dir.expects(:open).yields(dir)
|
38
|
-
result = Vagrant::Box.all(@env)
|
39
|
-
assert_equal ["foo", "bar", "baz"], result
|
40
|
-
end
|
41
|
-
|
42
|
-
should "ignore the files" do
|
43
|
-
dir = ["foo", "bar"]
|
44
|
-
files = [true, false]
|
45
|
-
Dir.expects(:open).yields(dir)
|
46
|
-
dir_sequence = sequence("directory")
|
47
|
-
dir.each_with_index do |dir, index|
|
48
|
-
File.expects(:directory?).with(File.join(@boxes_path, dir)).returns(files[index]).in_sequence(dir_sequence)
|
49
|
-
end
|
50
|
-
|
51
|
-
result = Vagrant::Box.all(@env)
|
52
|
-
assert_equal ["foo"], result
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "finding" do
|
57
|
-
setup do
|
58
|
-
@dir = "foo"
|
59
|
-
@name = "bar"
|
60
|
-
Vagrant::Box.stubs(:directory).with(@env, @name).returns(@dir)
|
61
|
-
end
|
62
|
-
|
63
|
-
should "return nil if the box doesn't exist" do
|
64
|
-
File.expects(:directory?).with(@dir).once.returns(false)
|
65
|
-
assert_nil Vagrant::Box.find(@env, @name)
|
66
|
-
end
|
67
|
-
|
68
|
-
should "return a box object with the proper name set" do
|
69
|
-
File.expects(:directory?).with(@dir).once.returns(true)
|
70
|
-
result = Vagrant::Box.find(@env, @name)
|
71
|
-
assert result
|
72
|
-
assert_equal @name, result.name
|
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
|
81
|
-
end
|
82
|
-
|
83
|
-
context "adding" do
|
84
|
-
setup do
|
85
|
-
@name = "foo"
|
86
|
-
@uri = "bar"
|
87
|
-
end
|
88
|
-
|
89
|
-
should "create a new instance, set the variables, and add it" do
|
90
|
-
box = mock("box")
|
91
|
-
box.expects(:name=).with(@name)
|
92
|
-
box.expects(:uri=).with(@uri)
|
93
|
-
box.expects(:env=).with(@env)
|
94
|
-
box.expects(:add).once
|
95
|
-
Vagrant::Box.expects(:new).returns(box)
|
96
|
-
Vagrant::Box.add(@env, @name, @uri)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "box directory" do
|
101
|
-
setup do
|
102
|
-
@name = "foo"
|
103
|
-
@box_dir = File.join(@env.boxes_path, @name)
|
104
|
-
end
|
105
|
-
|
106
|
-
should "return the boxes_path joined with the name" do
|
107
|
-
assert_equal @box_dir, Vagrant::Box.directory(@env, @name)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "instance methods" do
|
113
|
-
setup do
|
114
|
-
@box = Vagrant::Box.new
|
115
|
-
@box.env = mock_environment
|
116
|
-
end
|
117
|
-
|
118
|
-
should "execute the Add action when add is called" do
|
119
|
-
@box.expects(:execute!).with(Vagrant::Actions::Box::Add).once
|
120
|
-
@box.add
|
121
|
-
end
|
122
|
-
|
123
|
-
context "box directory" do
|
124
|
-
setup do
|
125
|
-
@box.name = "foo"
|
126
|
-
end
|
127
|
-
|
128
|
-
should "return the boxes_path joined with the name" do
|
129
|
-
result = mock("object")
|
130
|
-
Vagrant::Box.expects(:directory).with(@box.env, @box.name).returns(result)
|
131
|
-
assert result.equal?(@box.directory)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context "destroying" do
|
136
|
-
should "execute the destroy action" do
|
137
|
-
@box.expects(:execute!).with(Vagrant::Actions::Box::Destroy).once
|
138
|
-
@box.destroy
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "ovf file" do
|
143
|
-
setup do
|
144
|
-
@box.stubs(:directory).returns("foo")
|
145
|
-
|
146
|
-
@box.env.config.vm.box_ovf = "foo.ovf"
|
147
|
-
end
|
148
|
-
|
149
|
-
should "be the directory joined with the config ovf file" do
|
150
|
-
assert_equal File.join(@box.directory, @box.env.config.vm.box_ovf), @box.ovf_file
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|