2010-02-06 07:41:22 +00:00
|
|
|
begin
|
|
|
|
require File.expand_path('../.bundle/environment', __FILE__)
|
2010-01-22 05:07:01 +00:00
|
|
|
rescue LoadError
|
2010-02-06 07:41:22 +00:00
|
|
|
# Fallback on doing the resolve at runtime.
|
|
|
|
require "rubygems"
|
|
|
|
require "bundler"
|
|
|
|
Bundler.setup
|
2010-01-22 05:07:01 +00:00
|
|
|
end
|
|
|
|
|
2010-01-22 05:36:34 +00:00
|
|
|
# ruby-debug, not necessary, but useful if we have it
|
|
|
|
begin
|
|
|
|
require 'ruby-debug'
|
|
|
|
rescue LoadError; end
|
|
|
|
|
2010-01-30 07:22:03 +00:00
|
|
|
|
2010-02-10 07:08:23 +00:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'vagrant')
|
2010-01-22 05:54:23 +00:00
|
|
|
require 'contest'
|
2010-01-22 07:57:31 +00:00
|
|
|
require 'mocha'
|
2010-01-26 08:01:17 +00:00
|
|
|
|
2010-01-30 04:38:36 +00:00
|
|
|
class Test::Unit::TestCase
|
2010-02-13 19:56:33 +00:00
|
|
|
# Clears the previous config and sets up the new config
|
2010-02-10 07:08:23 +00:00
|
|
|
def mock_config
|
|
|
|
Vagrant::Config.instance_variable_set(:@config_runners, nil)
|
|
|
|
Vagrant::Config.instance_variable_set(:@config, nil)
|
2010-02-02 06:14:40 +00:00
|
|
|
|
2010-02-10 07:08:23 +00:00
|
|
|
Vagrant::Config.run do |config|
|
2010-02-02 06:14:40 +00:00
|
|
|
config.dotfile_name = ".hobo"
|
|
|
|
|
2010-02-03 08:17:32 +00:00
|
|
|
config.ssh.username = "foo"
|
|
|
|
config.ssh.password = "bar"
|
2010-02-02 06:14:40 +00:00
|
|
|
config.ssh.host = "baz"
|
2010-02-03 08:02:12 +00:00
|
|
|
config.ssh.forwarded_port_key = "ssh"
|
2010-02-02 06:14:40 +00:00
|
|
|
config.ssh.max_tries = 10
|
|
|
|
|
|
|
|
config.vm.base = "foo"
|
|
|
|
config.vm.base_mac = "42"
|
2010-02-06 08:01:47 +00:00
|
|
|
config.vm.project_directory = "/hobo"
|
2010-02-15 06:27:06 +00:00
|
|
|
config.vm.disk_image_format = 'VMDK'
|
2010-02-03 08:02:12 +00:00
|
|
|
config.vm.forward_port("ssh", 22, 2222)
|
2010-02-09 08:31:52 +00:00
|
|
|
|
2010-02-16 06:03:55 +00:00
|
|
|
config.package.name = 'vagrant'
|
|
|
|
config.package.extension = '.box'
|
2010-02-15 21:55:42 +00:00
|
|
|
|
2010-02-09 08:31:52 +00:00
|
|
|
config.chef.cookbooks_path = "cookbooks"
|
|
|
|
config.chef.provisioning_path = "/tmp/hobo-chef"
|
2010-02-10 02:16:19 +00:00
|
|
|
config.chef.json = {
|
|
|
|
:recipes => ["hobo_main"]
|
|
|
|
}
|
2010-02-15 21:55:42 +00:00
|
|
|
|
|
|
|
config.vagrant.home = '~/.home'
|
2010-02-02 06:14:40 +00:00
|
|
|
end
|
|
|
|
|
2010-02-15 06:27:06 +00:00
|
|
|
if block_given?
|
|
|
|
Vagrant::Config.run do |config|
|
|
|
|
yield config
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-02-15 06:27:06 +00:00
|
|
|
if block_given?
|
|
|
|
Vagrant::Config.run do |config|
|
|
|
|
yield config
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-02-10 07:08:23 +00:00
|
|
|
Vagrant::Config.execute!
|
2010-01-30 04:38:36 +00:00
|
|
|
end
|
2010-02-13 19:56:33 +00:00
|
|
|
|
|
|
|
# Sets up the mocks and instantiates an action for testing
|
2010-02-23 01:34:44 +00:00
|
|
|
def mock_action(action_klass, *args)
|
2010-02-13 19:56:33 +00:00
|
|
|
@vm = mock("vboxvm")
|
|
|
|
@mock_vm = mock("vm")
|
|
|
|
@mock_vm.stubs(:vm).returns(@vm)
|
|
|
|
@mock_vm.stubs(:vm=)
|
2010-02-15 07:48:44 +00:00
|
|
|
@mock_vm.stubs(:invoke_callback)
|
2010-02-16 03:02:23 +00:00
|
|
|
@mock_vm.stubs(:invoke_around_callback).yields
|
2010-02-23 01:34:44 +00:00
|
|
|
|
|
|
|
@action = action_klass.new(@mock_vm, *args)
|
2010-02-13 19:56:33 +00:00
|
|
|
|
|
|
|
[@mock_vm, @vm, @action]
|
|
|
|
end
|
2010-01-30 07:22:03 +00:00
|
|
|
end
|