Fix order-dependent specs
This commit is contained in:
@ -9,6 +9,7 @@ describe ExecutionEnvironmentsController do
|
||||
before do
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
allow(controller).to receive(:sync_to_runner_management).and_return(nil)
|
||||
allow(Runner.strategy_class).to receive(:available_images).and_return([])
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
|
@ -37,7 +37,7 @@ FactoryBot.define do
|
||||
created_by_teacher
|
||||
default_memory_limit
|
||||
default_cpu_limit
|
||||
docker_image { 'openhpi/co_execenv_java:8' }
|
||||
docker_image { 'openhpi/co_execenv_java:8-antlr' }
|
||||
file_type { association :dot_java, user: user }
|
||||
help
|
||||
name { 'Java 8' }
|
||||
|
@ -3,6 +3,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Authorization' do
|
||||
before { allow(Runner.strategy_class).to receive(:available_images).and_return([]) }
|
||||
|
||||
context 'when being an admin' do
|
||||
let(:user) { FactoryBot.create(:admin) }
|
||||
|
||||
|
@ -14,6 +14,8 @@ describe DockerClient do
|
||||
let(:workspace_path) { WORKSPACE_PATH }
|
||||
|
||||
before do
|
||||
docker_image = Docker::Image.new(Docker::Connection.new('http://example.org', {}), 'id' => SecureRandom.hex, 'RepoTags' => [FactoryBot.attributes_for(:java)[:docker_image]])
|
||||
allow(described_class).to receive(:find_image_by_tag).and_return(docker_image)
|
||||
described_class.initialize_environment
|
||||
allow(described_class).to receive(:container_creation_options).and_wrap_original do |original_method, *args, &block|
|
||||
result = original_method.call(*args, &block)
|
||||
@ -69,6 +71,10 @@ describe DockerClient do
|
||||
describe '.create_container' do
|
||||
let(:create_container) { described_class.create_container(execution_environment) }
|
||||
|
||||
after do
|
||||
FileUtils.rm_rf(workspace_path)
|
||||
end
|
||||
|
||||
it 'uses the correct Docker image' do
|
||||
expect(described_class).to receive(:find_image_by_tag).with(execution_environment.docker_image).and_call_original
|
||||
container = create_container
|
||||
@ -425,7 +431,7 @@ describe DockerClient do
|
||||
|
||||
it "returns the container's output" do
|
||||
expect(send_command[:stderr]).to be_blank
|
||||
expect(send_command[:stdout]).to start_with('root')
|
||||
expect(send_command[:stdout]).to start_with('user')
|
||||
end
|
||||
|
||||
it 'returns a corresponding status' do
|
||||
|
Reference in New Issue
Block a user