Refactor error classes
All runner errors are now in a single file. The not found error has been splitted into an error for runner not found and for environment not found.
This commit is contained in:

committed by
Sebastian Serth

parent
413f9b2705
commit
b48b45de9f
@ -53,7 +53,7 @@ describe Runner::Strategy::Poseidon do
|
||||
let(:response_status) { 404 }
|
||||
|
||||
it 'raises an error' do
|
||||
expect { action.call }.to raise_error(Runner::Error::NotFound, /Runner/)
|
||||
expect { action.call }.to raise_error(Runner::Error::RunnerNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -152,7 +152,7 @@ describe Runner::Strategy::Poseidon do
|
||||
let(:response_status) { 404 }
|
||||
|
||||
it 'raises an error' do
|
||||
expect { action.call }.to raise_error(Runner::Error::NotFound, /Execution environment/)
|
||||
expect { action.call }.to raise_error(Runner::Error::EnvironmentNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,23 +118,23 @@ describe Runner do
|
||||
context 'when the environment could not be found in the runner management' do
|
||||
let(:environment_id) { runner.execution_environment.id }
|
||||
|
||||
before { allow(strategy_class).to receive(:request_from_management).and_raise(Runner::Error::NotFound) }
|
||||
before { allow(strategy_class).to receive(:request_from_management).and_raise(Runner::Error::EnvironmentNotFound) }
|
||||
|
||||
it 'syncs the execution environment' do
|
||||
expect(strategy_class).to receive(:sync_environment).with(runner.execution_environment)
|
||||
runner.send(:request_new_id)
|
||||
rescue Runner::Error::NotFound
|
||||
rescue Runner::Error::EnvironmentNotFound
|
||||
# Ignored because this error is expected (see tests below).
|
||||
end
|
||||
|
||||
it 'raises an error when the environment could be synced' do
|
||||
allow(strategy_class).to receive(:sync_environment).with(runner.execution_environment).and_return(true)
|
||||
expect { runner.send(:request_new_id) }.to raise_error(Runner::Error::NotFound, /#{environment_id}.*successfully synced/)
|
||||
expect { runner.send(:request_new_id) }.to raise_error(Runner::Error::EnvironmentNotFound, /#{environment_id}.*successfully synced/)
|
||||
end
|
||||
|
||||
it 'raises an error when the environment could not be synced' do
|
||||
allow(strategy_class).to receive(:sync_environment).with(runner.execution_environment).and_return(false)
|
||||
expect { runner.send(:request_new_id) }.to raise_error(Runner::Error::NotFound, /#{environment_id}.*could not be synced/)
|
||||
expect { runner.send(:request_new_id) }.to raise_error(Runner::Error::EnvironmentNotFound, /#{environment_id}.*could not be synced/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user