Add execute_command
method to runner.rb
* This is now used by the score and test runs * This also re-enables the interactive shell for execution environments
This commit is contained in:
@ -75,12 +75,12 @@ describe ExecutionEnvironmentsController do
|
||||
let(:command) { 'which ruby' }
|
||||
|
||||
before do
|
||||
allow(DockerClient).to receive(:new).with(execution_environment: execution_environment).and_call_original
|
||||
allow_any_instance_of(DockerClient).to receive(:execute_arbitrary_command).with(command)
|
||||
runner = instance_double 'runner'
|
||||
allow(Runner).to receive(:for).with(user, execution_environment).and_return runner
|
||||
allow(runner).to receive(:execute_command).and_return({})
|
||||
post :execute_command, params: {command: command, id: execution_environment.id}
|
||||
end
|
||||
|
||||
expect_assigns(docker_client: DockerClient)
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_json
|
||||
expect_status(200)
|
||||
|
@ -149,10 +149,12 @@ describe ExecutionEnvironment do
|
||||
|
||||
before { allow(DockerClient).to receive(:find_image_by_tag).and_return(Object.new) }
|
||||
|
||||
it 'instantiates a Docker client' do
|
||||
expect(DockerClient).to receive(:new).with(execution_environment: execution_environment).and_call_original
|
||||
allow_any_instance_of(DockerClient).to receive(:execute_arbitrary_command).and_return({})
|
||||
it 'instantiates a Runner' do
|
||||
runner = instance_double 'runner'
|
||||
allow(Runner).to receive(:for).with(execution_environment.author, execution_environment).and_return runner
|
||||
allow(runner).to receive(:execute_command).and_return({})
|
||||
working_docker_image?
|
||||
expect(runner).to have_received(:execute_command).once
|
||||
end
|
||||
|
||||
it 'executes the validation command' do
|
||||
|
@ -247,7 +247,7 @@ describe Runner do
|
||||
before { allow(strategy_class).to receive(:request_from_management).and_return(nil) }
|
||||
|
||||
it 'raises an error' do
|
||||
expect { described_class.for(user, exercise) }.to raise_error(Runner::Error::Unknown, /could not be saved/)
|
||||
expect { described_class.for(user, exercise.execution_environment) }.to raise_error(Runner::Error::Unknown, /could not be saved/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -255,12 +255,12 @@ describe Runner do
|
||||
let!(:existing_runner) { FactoryBot.create(:runner, user: user, execution_environment: exercise.execution_environment) }
|
||||
|
||||
it 'returns the existing runner' do
|
||||
new_runner = described_class.for(user, exercise)
|
||||
new_runner = described_class.for(user, exercise.execution_environment)
|
||||
expect(new_runner).to eq(existing_runner)
|
||||
end
|
||||
|
||||
it 'sets the strategy' do
|
||||
runner = described_class.for(user, exercise)
|
||||
runner = described_class.for(user, exercise.execution_environment)
|
||||
expect(runner.strategy).to be_present
|
||||
end
|
||||
end
|
||||
@ -269,7 +269,7 @@ describe Runner do
|
||||
before { allow(strategy_class).to receive(:request_from_management).and_return(runner_id) }
|
||||
|
||||
it 'returns a new runner' do
|
||||
runner = described_class.for(user, exercise)
|
||||
runner = described_class.for(user, exercise.execution_environment)
|
||||
expect(runner).to be_valid
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user