Refactor sync_environment methods
* Add delete_environment method * Change return value to allow raising an exception
This commit is contained in:
@ -46,7 +46,10 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before { delete :destroy, params: {id: execution_environment.id} }
|
||||
before do
|
||||
allow(Runner.strategy_class).to receive(:remove_environment).and_return(true)
|
||||
delete :destroy, params: {id: execution_environment.id}
|
||||
end
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
|
||||
@ -55,6 +58,10 @@ describe ExecutionEnvironmentsController do
|
||||
expect { delete :destroy, params: {id: execution_environment.id} }.to change(ExecutionEnvironment, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'removes the execution environment from the runner management' do
|
||||
expect(Runner.strategy_class).to have_received(:remove_environment)
|
||||
end
|
||||
|
||||
expect_redirect(:execution_environments)
|
||||
end
|
||||
|
||||
|
@ -141,11 +141,11 @@ describe Runner::Strategy::Poseidon do
|
||||
end
|
||||
|
||||
shared_examples 'returns false when the api request failed' do |status|
|
||||
it "returns false on status #{status}" do
|
||||
it "raises an exception on status #{status}" do
|
||||
faraday_connection = instance_double 'Faraday::Connection'
|
||||
allow(described_class).to receive(:http_connection).and_return(faraday_connection)
|
||||
allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: status))
|
||||
expect(action.call).to be_falsey
|
||||
expect { action.call }.to raise_exception Runner::Error::UnexpectedResponse
|
||||
end
|
||||
end
|
||||
|
||||
@ -157,11 +157,11 @@ describe Runner::Strategy::Poseidon do
|
||||
include_examples 'returns false when the api request failed', status
|
||||
end
|
||||
|
||||
it 'returns false if Faraday raises an error' do
|
||||
it 'raises an exception if Faraday raises an error' do
|
||||
faraday_connection = instance_double 'Faraday::Connection'
|
||||
allow(described_class).to receive(:http_connection).and_return(faraday_connection)
|
||||
allow(faraday_connection).to receive(:put).and_raise(Faraday::TimeoutError)
|
||||
expect(action.call).to be_falsey
|
||||
expect { action.call }.to raise_exception Runner::Error::FaradayError
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,7 +233,7 @@ describe Runner do
|
||||
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)
|
||||
allow(strategy_class).to receive(:sync_environment).with(runner.execution_environment).and_raise(Runner::Error::EnvironmentNotFound)
|
||||
expect { runner.send(:request_new_id) }.to raise_error(Runner::Error::EnvironmentNotFound, /#{environment_id}.*could not be synced/)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user