Raise correct exception on domain not found

Update spec to check the actually exception raised and fix the code to
raise the correct one instead of throwing constant not defined.
This commit is contained in:
Darragh Bailey 2016-01-25 19:11:54 +00:00
parent afb53addb1
commit dde1b9bd43
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,5 @@
require 'log4r' require 'log4r'
require 'vagrant-libvirt/errors'
require 'vagrant-libvirt/util/timer' require 'vagrant-libvirt/util/timer'
require 'vagrant/util/retryable' require 'vagrant/util/retryable'
@ -21,8 +22,11 @@ module VagrantPlugins
env[:metrics] ||= {} env[:metrics] ||= {}
# Get domain object # Get domain object
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s) domain = env[:machine].provider.driver.get_domain(env[:machine].id.to_s)
raise NoDomainError if domain == nil if domain == nil
raise Errors::NoDomainError,
:error_message => "Domain #{env[:machine].id} not found"
end
# Wait for domain to obtain an ip address. Ip address is searched # Wait for domain to obtain an ip address. Ip address is searched
# from arp table, either localy or remotely via ssh, if libvirt # from arp table, either localy or remotely via ssh, if libvirt

View File

@ -23,7 +23,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
it "raises exception" do it "raises exception" do
expect(app).to_not receive(:call) expect(app).to_not receive(:call)
expect{subject.call(env)}.to raise_error expect{subject.call(env)}.to raise_error(::VagrantPlugins::ProviderLibvirt::Errors::NoDomainError,
/No domain found. Domain dummy-vagrant_dummy not found/)
end end
end end
end end