Project

General

Profile

« Previous | Next » 

Revision f57d42f5

Added by Tristan Robert almost 6 years ago

Fixes #23859 - Fix vm_exists? method

Fix related tests

View differences:

test/models/host_test.rb
:compute_resource => compute_resources(:ec2),
:organization => nil,
:location => nil)
host.stubs(:vm_exists?).returns(true)
host.stubs(:vm_exists?).returns(false)
host.expects(:queue_compute_create)
assert host.valid?, host.errors.full_messages.to_sentence
assert_equal compute_attributes(:one).vm_attrs, host.compute_attributes
......
:compute_profile => compute_profiles(:two),
:organization => nil,
:location => nil)
host.stubs(:vm_exists?).returns(true)
host.stubs(:vm_exists?).returns(false)
host.expects(:queue_compute_create)
assert host.valid?, host.errors.full_messages.to_sentence
assert_equal compute_attributes(:three).vm_attrs, host.compute_attributes
......
end
test "should create host with compute profile when compute_attributes are empty" do
@host.stubs(:vm_exists?).returns(true)
@host.stubs(:vm_exists?).returns(false)
@host.compute_resource.expects(:create_vm).once.with do |vm_attrs|
vm_attrs['flavor_id'] == @compute_attrs.vm_attrs['flavor_id'] &&
vm_attrs['availability_zone'] == @compute_attrs.vm_attrs['availability_zone']
......
test "should create host with compute profile when compute_attributes are nil" do
@host.compute_attributes = nil
@host.stubs(:vm_exists?).returns(true)
@host.stubs(:vm_exists?).returns(false)
@host.compute_resource.expects(:create_vm).once.with do |vm_attrs|
vm_attrs['flavor_id'] == @compute_attrs.vm_attrs['flavor_id'] &&
vm_attrs['availability_zone'] == @compute_attrs.vm_attrs['availability_zone']
......
vm_attrs['flavor_id'].nil? &&
vm_attrs['availability_zone'].nil?
end
@host.stubs(:vm_exists?).returns(true)
@host.stubs(:vm_exists?).returns(false)
@host.valid?
@host.send(:setCompute)

Also available in: Unified diff