Moving unit tests to test/unit

This commit is contained in:
Mitchell Hashimoto 2011-08-28 23:10:32 -07:00
parent f6e6d7e834
commit ce5d989384
89 changed files with 18 additions and 2 deletions

View File

@ -6,6 +6,6 @@ Bundler::GemHelper.install_tasks
task :default => :test task :default => :test
Rake::TestTask.new do |t| Rake::TestTask.new do |t|
t.libs << "test" t.libs << "test/unit"
t.pattern = 'test/**/*_test.rb' t.pattern = 'test/unit/**/*_test.rb'
end end

View File

@ -27,6 +27,7 @@ class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase
def mock_vm(options={}) def mock_vm(options={})
options = { options = {
:running? => true, :running? => true,
:accessible? => true,
:uuid => :foo :uuid => :foo
}.merge(options) }.merge(options)
@ -50,6 +51,12 @@ class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase
@instance.used_ports @instance.used_ports
end end
should "ignore VMs which aren't accessible" do
@vms << mock_vm(:accessible? => false)
@vms[0].expects(:forwarded_ports).never
@instance.used_ports
end
should "ignore VMs of the same uuid" do should "ignore VMs of the same uuid" do
@vms << mock_vm(:uuid => @vm.uuid) @vms << mock_vm(:uuid => @vm.uuid)
@vms[0].expects(:forwarded_ports).never @vms[0].expects(:forwarded_ports).never

View File

@ -262,6 +262,7 @@ class VMTest < Test::Unit::TestCase
setup do setup do
@mock_vm.stubs(:running?).returns(false) @mock_vm.stubs(:running?).returns(false)
@mock_vm.stubs(:saved?).returns(false) @mock_vm.stubs(:saved?).returns(false)
@mock_vm.stubs(:accessible?).returns(true)
end end
should "not do anything if the VM is already running" do should "not do anything if the VM is already running" do
@ -286,6 +287,14 @@ class VMTest < Test::Unit::TestCase
@vm.env.actions.expects(:run).with(:start, :foo => :bar).once @vm.env.actions.expects(:run).with(:start, :foo => :bar).once
@vm.start(:foo => :bar) @vm.start(:foo => :bar)
end end
should "raise an exception if the VM is not accessible" do
@mock_vm.stubs(:accessible?).returns(false)
assert_raises(Vagrant::Errors::VMInaccessible) {
@vm.start
}
end
end end
end end
end end