Fix order-dependent specs

This commit is contained in:
Sebastian Serth
2021-11-04 18:34:44 +01:00
parent d033f71ae3
commit 7f47af99cb
6 changed files with 13 additions and 4 deletions

View File

@ -17,7 +17,7 @@ jobs:
--health-timeout 5s
--health-retries 5
co_execenv_java:
image: openhpi/co_execenv_java:8
image: openhpi/co_execenv_java:8-antlr
steps:
- name: Configure Docker host

View File

@ -43,7 +43,7 @@ rspec:
- rake db:schema:load
- rake db:migrate
- docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
- docker pull openhpi/co_execenv_java:8
- docker pull openhpi/co_execenv_java:8-antlr
script:
- rspec --format progress
coverage: '/\(\d+.\d+\%\) covered/'

View File

@ -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

View File

@ -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' }

View File

@ -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) }

View File

@ -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