vagrant 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +94 -51
- 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/lib/vagrant/vm.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Vagrant::Config.run do |config|
|
2
2
|
# All Vagrant configuration is done here. For a detailed explanation
|
3
|
-
# and listing of configuration options, please
|
3
|
+
# and listing of configuration options, please view the documentation
|
4
4
|
# online.
|
5
5
|
|
6
6
|
# Every Vagrant virtual environment requires a box to build off of.
|
7
|
-
config.vm.box = "
|
7
|
+
config.vm.box = "<%= default_box %>"
|
8
8
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
log_level <%= log_level.inspect %>
|
2
|
+
log_location STDOUT
|
3
|
+
node_name "<%= node_name %>"
|
4
|
+
ssl_verify_mode :verify_none
|
5
|
+
chef_server_url "<%= chef_server_url %>"
|
6
|
+
|
7
|
+
validation_client_name "<%= validation_client_name %>"
|
8
|
+
validation_key "<%= validation_key %>"
|
9
|
+
client_key "<%= client_key %>"
|
10
|
+
|
11
|
+
file_store_path "/srv/chef/file_store"
|
12
|
+
file_cache_path "/srv/chef/cache"
|
13
|
+
|
14
|
+
pid_file "/var/run/chef/chef-client.pid"
|
15
|
+
|
16
|
+
Mixlib::Log::Formatter.show_time = true
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# Using YAMLs Block Literals to preserve new lines
|
2
|
+
# http://en.wikipedia.org/wiki/YAML#Newlines_preserved
|
3
|
+
# In short, | means keep new lines, trim whitespace left and right
|
4
|
+
# The |- does the above, but trims the new line at the end of all text
|
5
|
+
|
6
|
+
:box_already_exists: |-
|
7
|
+
This box appears to already exist! Please call `vagrant box remove <%= box_name %>`
|
8
|
+
and then try to add it again.
|
9
|
+
:box_add_already_exists: |-
|
10
|
+
A box with the name '<%= box_name %>' already exists, please use another name or use `vagrant box remove <%= box_name %>`
|
11
|
+
:box_download_unknown_type: |-
|
12
|
+
Unknown URI type for box download.
|
13
|
+
:box_remove_doesnt_exist: |-
|
14
|
+
The box you're attempting to remove does not exist!
|
15
|
+
:box_specified_doesnt_exist: |-
|
16
|
+
Specified box `<%= box_name %>` does not exist!
|
17
|
+
|
18
|
+
The box must be added through the `vagrant box add` command. Please view
|
19
|
+
the documentation associated with the command for more information.
|
20
|
+
:box_not_specified: |-
|
21
|
+
No base box was specified! A base box is required as a staring point
|
22
|
+
for every vagrant virtual machine. Please specify one in your Vagrantfile
|
23
|
+
using `config.vm.box`
|
24
|
+
:chef_base_invalid_provisioner: |-
|
25
|
+
Vagrant::Provisioners::Chef is not a valid provisioner! Use ChefSolo or ChefServer instead.
|
26
|
+
:chef_server_url_required: |-
|
27
|
+
Chef server provisioning requires that the `config.chef.chef_server_url` be set to the
|
28
|
+
URL of your chef server. Examples include "http://12.12.12.12:4000" and
|
29
|
+
"http://myserver.com:4000" (the port of course can be different, but 4000 is the default)
|
30
|
+
:chef_server_validation_key_required: |-
|
31
|
+
Chef server provisioning requires that the `config.chef.validation_key_path` configuration
|
32
|
+
be set to a path on your local machine of the validation key used to register the
|
33
|
+
VM with the chef server.
|
34
|
+
:chef_server_validation_key_doesnt_exist: |-
|
35
|
+
The validation key set for `config.chef.validation_key_path` does not exist! This
|
36
|
+
file needs to exist so it can be uploaded to the virtual machine. It is
|
37
|
+
currently set to "<%= Vagrant.config.chef.validation_key_path %>"
|
38
|
+
:command_box_invalid: |-
|
39
|
+
Please specify a valid action to take on the boxes, either
|
40
|
+
`add` or `remove`. Examples:
|
41
|
+
|
42
|
+
vagrant box add name uri
|
43
|
+
vagrant box remove name
|
44
|
+
vagrant box list
|
45
|
+
:command_deprecation_down: |-
|
46
|
+
`vagrant down` is now `vagrant destroy`. Please use that command instead. This
|
47
|
+
warning will be removed in future versions.
|
48
|
+
:dotfile_error: |-
|
49
|
+
The dotfile which Vagrant uses to store the UUID of the project's
|
50
|
+
virtual machine already exists and is not a file! The dotfile is
|
51
|
+
currently configured to be `<%= env.dotfile_path %>`
|
52
|
+
|
53
|
+
To change this value, please see `config.vagrant.dotfile_name`
|
54
|
+
|
55
|
+
Are you trying to use Vagrant from your home directory? This is the
|
56
|
+
leading cause of this error message. To resolve this, simply use a
|
57
|
+
different directory. Or, if you really want to run Vagrant from your
|
58
|
+
home directory, modify the `config.vagrant.dotfile_name` configuration
|
59
|
+
key.
|
60
|
+
:downloader_file_doesnt_exist: |-
|
61
|
+
The given box does not exist on the file system:
|
62
|
+
|
63
|
+
<%= source_url %>
|
64
|
+
:environment_not_created: |-
|
65
|
+
The task you're trying to run requires that the vagrant environment
|
66
|
+
already be created, but unfortunately this vagrant still appears to
|
67
|
+
have no box! You can setup the environment by setting up your
|
68
|
+
<%= Vagrant::Environment::ROOTFILE_NAME %> and running `vagrant up`
|
69
|
+
:package_include_file_doesnt_exist: |-
|
70
|
+
File specified to include: '<%= filename %>' does not exist!
|
71
|
+
:package_requires_export: |-
|
72
|
+
Package must be used in conjunction with export.
|
73
|
+
:provisioner_invalid_class: |-
|
74
|
+
Provisioners must be an instance of Vagrant::Provisioners::Base
|
75
|
+
:provisioner_unknown_type: |-
|
76
|
+
Unknown provisioner type: <%= provisioner %>
|
77
|
+
:rootfile_already_exists: |-
|
78
|
+
It looks like this directory is already setup for vagrant! (A <%= Vagrant::Environment::ROOTFILE_NAME %>
|
79
|
+
already exists.)
|
80
|
+
:rootfile_not_found: |-
|
81
|
+
A `<%= Vagrant::Environment::ROOTFILE_NAME %>` was not found! This file is required for vagrant to run
|
82
|
+
since it describes the expected environment that vagrant is supposed
|
83
|
+
to manage. Please create a `<%= Vagrant::Environment::ROOTFILE_NAME %>` and place it in your project
|
84
|
+
root.
|
85
|
+
:ssh_bad_permissions: |-
|
86
|
+
The private key to connect to this box via SSH has invalid permissions
|
87
|
+
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
|
88
|
+
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
|
89
|
+
permissions on the following file to 0600 and then try running this command again:
|
90
|
+
|
91
|
+
<%= key_path %>
|
92
|
+
:ssh_unavailable_windows: |-
|
93
|
+
`vagrant ssh` isn't available on the Windows platform. The
|
94
|
+
vagrant.ppk file is available at
|
95
|
+
|
96
|
+
<%= key_path %>.ppk
|
97
|
+
|
98
|
+
for use with Putty. To do this create a new Putty session for
|
99
|
+
`vagrant@localhost` on port `<%= ssh_port %>`, in the Connection>SSH>Auth
|
100
|
+
configuration section navigate to the vagrant.ppk file,
|
101
|
+
select it, save the session for later use, and connect.
|
102
|
+
|
103
|
+
For a more detailed guide please consult:
|
104
|
+
|
105
|
+
http://vagrantup.com/docs/getting-started/windows.html
|
106
|
+
|
107
|
+
:virtualbox_import_failure: |-
|
108
|
+
The VM import failed! Try running `VBoxManage import` on the box file
|
109
|
+
manually for more verbose error output.
|
110
|
+
:virtualbox_invalid_version: |-
|
111
|
+
Vagrant has detected that you have VirtualBox version <%= version %> installed!
|
112
|
+
Vagrant requires that you use at least VirtualBox version 3.1. Please install
|
113
|
+
a more recent version of VirtualBox to continue.
|
114
|
+
:virtualbox_not_detected: |-
|
115
|
+
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
|
116
|
+
If VirtualBox is installed, it may be an incorrect version. Vagrant currently
|
117
|
+
only supports VirtualBox 3.1.x. Please install the proper version to continue.
|
118
|
+
:vm_failed_to_boot: |-
|
119
|
+
Failed to connect to VM! Failed to boot?
|
120
|
+
:vm_base_not_found: |-
|
121
|
+
The specified base VM "<%= name %>" was not found.
|
122
|
+
:vm_not_running: |-
|
123
|
+
VM is not running! Nothing to shut down!
|
124
|
+
:vm_not_running_for_suspend: |-
|
125
|
+
The vagrant virtual environment you are trying to suspend must be running to be suspended.
|
126
|
+
:vm_not_suspended: |-
|
127
|
+
The vagrant virtual environment you are trying to resume is not in a suspended state.
|
128
|
+
:vm_port_collision: |-
|
129
|
+
Vagrant cannot forward the specified ports on this VM, since they
|
130
|
+
would collide with another VirtualBox virtual machine's forwarded
|
131
|
+
ports! The "<%= name %>" forwarded port (<%= hostport %>) is already in use on the host
|
132
|
+
machine.
|
133
|
+
|
134
|
+
To fix this, modify your current projects Vagrantfile to use another
|
135
|
+
port. Example, where '1234' would be replaced by a unique host port:
|
136
|
+
|
137
|
+
config.vm.forward_port("<%= name %>", <%= guestport %>, 1234)
|
138
|
+
:vm_power_off_to_move_hd: |-
|
139
|
+
The virtual machine must be powered off to move its disk.
|
140
|
+
:vm_power_off_to_package: |-
|
141
|
+
The vagrant virtual environment you are trying to package must be powered off.
|
142
|
+
:vm_mount_fail: |-
|
143
|
+
Failed to mount shared folders. vboxsf was not available.
|
144
|
+
:vm_ssh_auth_failed: |-
|
145
|
+
SSH authentication failed! While this could be due to a variety of reasons,
|
146
|
+
the two most common are: private key path is incorrect or you're using a box
|
147
|
+
which was built for Vagrant 0.1.x.
|
148
|
+
|
149
|
+
Vagrant 0.2.x dropped support for password-based authentication. If you're
|
150
|
+
tring to `vagrant up` a box which does not support Vagrant's private/public
|
151
|
+
keypair, then this error will be raised. To resolve this, read the guide
|
152
|
+
on converting base boxes from password-based to keypairs here:
|
153
|
+
|
154
|
+
http://vagrantup.com/docs/converting_password_to_key_ssh.html
|
155
|
+
|
156
|
+
If the box was built for 0.2.x and contains a custom public key, perhaps
|
157
|
+
the path to the private key is incorrect. Check your `config.ssh.private_key_path`.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Vagrant::Config.run do |config|
|
2
|
+
# This Vagrantfile is auto-generated by `vagrant package` to contain
|
3
|
+
# the MAC address of the box. Custom configuration should be placed in
|
4
|
+
# the actual `Vagrantfile` in this box.
|
5
|
+
config.vm.base_mac = "<%= base_mac %>"
|
6
|
+
end
|
7
|
+
|
8
|
+
# Load include vagrant file if it exists after the auto-generated
|
9
|
+
# so it can override any of the settings
|
10
|
+
include_vagrantfile = File.expand_path(File.join(File.dirname(__FILE__), "include", "Vagrantfile"))
|
11
|
+
load include_vagrantfile if File.exist?(include_vagrantfile)
|
data/test/test_helper.rb
CHANGED
@@ -3,8 +3,6 @@ begin
|
|
3
3
|
rescue LoadError
|
4
4
|
# Fallback on doing the resolve at runtime.
|
5
5
|
require "rubygems"
|
6
|
-
require "bundler"
|
7
|
-
Bundler.setup
|
8
6
|
end
|
9
7
|
|
10
8
|
# ruby-debug, not necessary, but useful if we have it
|
@@ -18,9 +16,11 @@ require 'contest'
|
|
18
16
|
require 'mocha'
|
19
17
|
|
20
18
|
class Test::Unit::TestCase
|
21
|
-
#
|
22
|
-
def
|
23
|
-
Vagrant::
|
19
|
+
# Mocks an environment, setting it up with the given config.
|
20
|
+
def mock_environment
|
21
|
+
environment = Vagrant::Environment.new
|
22
|
+
|
23
|
+
Vagrant::Config.reset!(environment)
|
24
24
|
|
25
25
|
Vagrant::Config.run do |config|
|
26
26
|
config.vagrant.dotfile_name = ".vagrant"
|
@@ -49,8 +49,10 @@ class Test::Unit::TestCase
|
|
49
49
|
config.chef.chef_server_url = "http://localhost:4000"
|
50
50
|
config.chef.validation_key_path = "validation.pem"
|
51
51
|
config.chef.client_key_path = "/zoo/foo/bar.pem"
|
52
|
+
config.chef.node_name = "baz"
|
52
53
|
config.chef.cookbooks_path = "cookbooks"
|
53
54
|
config.chef.provisioning_path = "/tmp/vagrant-chef"
|
55
|
+
config.chef.log_level = :info
|
54
56
|
config.chef.json = {
|
55
57
|
:recipes => ["vagrant_main"]
|
56
58
|
}
|
@@ -64,13 +66,10 @@ class Test::Unit::TestCase
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
|
68
|
-
Vagrant::Config.run do |config|
|
69
|
-
yield config
|
70
|
-
end
|
71
|
-
end
|
69
|
+
config = Vagrant::Config.execute!
|
72
70
|
|
73
|
-
|
71
|
+
environment.instance_variable_set(:@config, config)
|
72
|
+
environment
|
74
73
|
end
|
75
74
|
|
76
75
|
# Sets up the mocks and instantiates an action for testing
|
@@ -85,11 +84,12 @@ class Test::Unit::TestCase
|
|
85
84
|
mock_vm.stubs(:invoke_callback)
|
86
85
|
mock_vm.stubs(:invoke_around_callback).yields
|
87
86
|
mock_vm.stubs(:actions).returns([action])
|
87
|
+
mock_vm.stubs(:env).returns(mock_environment)
|
88
88
|
|
89
89
|
[mock_vm, vm, action]
|
90
90
|
end
|
91
91
|
|
92
|
-
def stub_default_action_dependecies(mock
|
92
|
+
def stub_default_action_dependecies(mock)
|
93
93
|
mock.stubs(:precedes).returns([])
|
94
94
|
mock.stubs(:follows).returns([])
|
95
95
|
end
|
@@ -103,6 +103,3 @@ class Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
class MockAction; end
|
107
|
-
class MockActionOther; end
|
108
|
-
|
@@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
|
3
3
|
class AddBoxActionTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Add)
|
6
|
-
mock_config
|
7
6
|
end
|
8
7
|
|
9
8
|
context "prepare" do
|
@@ -27,7 +26,7 @@ class AddBoxActionTest < Test::Unit::TestCase
|
|
27
26
|
|
28
27
|
should "result in an action exception if the box already exists" do
|
29
28
|
File.expects(:exists?).once.returns(true)
|
30
|
-
@runner.expects(:name).
|
29
|
+
@runner.expects(:name).once.returns('foo')
|
31
30
|
@runner.expects(:add_action).never
|
32
31
|
assert_raise Vagrant::Actions::ActionException do
|
33
32
|
@action.prepare
|
@@ -6,24 +6,20 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
6
6
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Download)
|
7
7
|
@runner.stubs(:uri).returns(@uri)
|
8
8
|
@runner.stubs(:temp_path=)
|
9
|
-
mock_config
|
10
9
|
|
11
|
-
|
10
|
+
@runner.env.stubs(:tmp_path).returns("foo")
|
12
11
|
end
|
13
12
|
|
14
13
|
context "preparing" do
|
15
14
|
setup do
|
16
|
-
@uri = mock("uri")
|
17
|
-
@uri.stubs(:is_a?).returns(false)
|
18
|
-
URI.stubs(:parse).returns(@uri)
|
19
|
-
|
20
15
|
@downloader = mock("downloader")
|
21
16
|
Vagrant::Downloaders::File.any_instance.stubs(:prepare)
|
22
17
|
Vagrant::Downloaders::HTTP.any_instance.stubs(:prepare)
|
23
18
|
end
|
24
19
|
|
25
|
-
should "raise an exception if no URI type is matched" do
|
26
|
-
|
20
|
+
should "raise an exception if no URI type is matched" do\
|
21
|
+
Vagrant::Downloaders::File.expects(:match?).returns(false)
|
22
|
+
Vagrant::Downloaders::HTTP.expects(:match?).returns(false)
|
27
23
|
assert_raises(Vagrant::Actions::ActionException) {
|
28
24
|
@action.prepare
|
29
25
|
}
|
@@ -32,21 +28,31 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
32
28
|
should "call #prepare on the downloader" do
|
33
29
|
@downloader.expects(:prepare).with(@runner.uri).once
|
34
30
|
Vagrant::Downloaders::File.expects(:new).returns(@downloader)
|
35
|
-
|
31
|
+
expect_file
|
36
32
|
@action.prepare
|
37
33
|
end
|
38
34
|
|
39
|
-
should "set the downloader to file if
|
40
|
-
|
35
|
+
should "set the downloader to file if the uri provided is a file" do
|
36
|
+
expect_file
|
41
37
|
@action.prepare
|
42
38
|
assert @action.downloader.is_a?(Vagrant::Downloaders::File)
|
43
39
|
end
|
44
40
|
|
45
|
-
should "set the downloader to HTTP if
|
46
|
-
|
41
|
+
should "set the downloader to HTTP if the uri provided is a valid url" do
|
42
|
+
expect_http
|
47
43
|
@action.prepare
|
48
44
|
assert @action.downloader.is_a?(Vagrant::Downloaders::HTTP)
|
49
45
|
end
|
46
|
+
|
47
|
+
def expect_file
|
48
|
+
Vagrant::Downloaders::File.expects(:match?).returns(true)
|
49
|
+
Vagrant::Downloaders::HTTP.expects(:match?).returns(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
def expect_http
|
53
|
+
Vagrant::Downloaders::File.expects(:match?).returns(false)
|
54
|
+
Vagrant::Downloaders::HTTP.expects(:match?).returns(true)
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
context "executing" do
|
@@ -81,13 +87,16 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
81
87
|
|
82
88
|
context "tempfile" do
|
83
89
|
should "create a tempfile in the vagrant tmp directory" do
|
84
|
-
|
90
|
+
File.expects(:open).with { |name, bitmask|
|
91
|
+
name =~ /#{Vagrant::Actions::Box::Download::BASENAME}/ && name =~ /#{@runner.env.tmp_path}/
|
92
|
+
}.once
|
85
93
|
@action.with_tempfile
|
86
94
|
end
|
87
95
|
|
96
|
+
|
88
97
|
should "yield the tempfile object" do
|
89
98
|
@tempfile = mock("tempfile")
|
90
|
-
|
99
|
+
File.expects(:open).yields(@tempfile)
|
91
100
|
|
92
101
|
@action.with_tempfile do |otherfile|
|
93
102
|
assert @tempfile.equal?(otherfile)
|
@@ -95,6 +104,22 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|
95
104
|
end
|
96
105
|
end
|
97
106
|
|
107
|
+
context "file options" do
|
108
|
+
should "include add binary bit to options on windows platform" do
|
109
|
+
# This constant is not defined on non-windows platforms, so define it here
|
110
|
+
File::BINARY = 4096 unless defined?(File::BINARY)
|
111
|
+
|
112
|
+
Mario::Platform.expects(:windows?).returns(true)
|
113
|
+
assert_equal @action.file_options, File::CREAT|File::EXCL|File::WRONLY|File::BINARY
|
114
|
+
end
|
115
|
+
|
116
|
+
should "not include binary bit on other platforms" do
|
117
|
+
Mario::Platform.expects(:windows?).returns(false)
|
118
|
+
assert_equal @action.file_options, File::CREAT|File::EXCL|File::WRONLY
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
98
123
|
context "cleaning up" do
|
99
124
|
setup do
|
100
125
|
@temp_path = "foo"
|
@@ -5,9 +5,8 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
5
5
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Unpackage)
|
6
6
|
@runner.stubs(:name).returns("foo")
|
7
7
|
@runner.stubs(:temp_path).returns("bar")
|
8
|
-
mock_config
|
9
8
|
|
10
|
-
|
9
|
+
@runner.env.stubs(:boxes_path).returns("bar")
|
11
10
|
end
|
12
11
|
|
13
12
|
context "executing" do
|
@@ -68,7 +67,7 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
|
68
67
|
|
69
68
|
should "error and exit if the directory exists" do
|
70
69
|
File.expects(:directory?).returns(true)
|
71
|
-
@action.expects(:error_and_exit).once
|
70
|
+
@action.expects(:error_and_exit).with(:box_already_exists, :box_name => @runner.name).once
|
72
71
|
@action.setup_box_dir
|
73
72
|
end
|
74
73
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
2
|
|
3
3
|
class CollectionTest < Test::Unit::TestCase
|
4
|
+
class MockAction; end
|
5
|
+
class MockActionOther; end
|
6
|
+
|
4
7
|
context "checking uniqueness" do
|
5
8
|
setup do
|
6
9
|
@actions = Vagrant::Actions::Collection.new([1])
|
@@ -10,14 +13,14 @@ class CollectionTest < Test::Unit::TestCase
|
|
10
13
|
@actions << 1
|
11
14
|
assert @actions.duplicates?
|
12
15
|
end
|
13
|
-
|
16
|
+
|
14
17
|
should "return false it all the classes are unique" do
|
15
18
|
@actions << 1.0 << "foo"
|
16
19
|
assert !@actions.duplicates?
|
17
20
|
end
|
18
21
|
|
19
22
|
should "raise an exception when there are duplicates" do
|
20
|
-
@actions << 1
|
23
|
+
@actions << 1
|
21
24
|
assert_raise Vagrant::Actions::DuplicateActionException do
|
22
25
|
@actions.duplicates!
|
23
26
|
end
|
@@ -42,7 +45,7 @@ class CollectionTest < Test::Unit::TestCase
|
|
42
45
|
stub_default_action_dependecies(@mock_action)
|
43
46
|
stub_default_action_dependecies(@mock_action2)
|
44
47
|
end
|
45
|
-
|
48
|
+
|
46
49
|
context "that come before an action" do
|
47
50
|
setup do
|
48
51
|
@mock_action.stubs(:follows).returns([MockActionOther])
|
@@ -52,7 +55,7 @@ class CollectionTest < Test::Unit::TestCase
|
|
52
55
|
collection.new([@mock_action]).dependencies!
|
53
56
|
end
|
54
57
|
end
|
55
|
-
|
58
|
+
|
56
59
|
should "not raise an exception if they are met" do
|
57
60
|
assert_nothing_raised do
|
58
61
|
collection.new([@mock_action2, @mock_action]).dependencies!
|
@@ -97,7 +100,7 @@ class CollectionTest < Test::Unit::TestCase
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
100
|
-
|
103
|
+
|
101
104
|
context "klasses" do
|
102
105
|
should "return a list of the collection element's classes" do
|
103
106
|
@action = mock('action')
|