Fix order-dependent specs
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
co_execenv_java:
|
co_execenv_java:
|
||||||
image: openhpi/co_execenv_java:8
|
image: openhpi/co_execenv_java:8-antlr
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Configure Docker host
|
- name: Configure Docker host
|
||||||
|
@ -43,7 +43,7 @@ rspec:
|
|||||||
- rake db:schema:load
|
- rake db:schema:load
|
||||||
- rake db:migrate
|
- rake db:migrate
|
||||||
- docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
|
- docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
|
||||||
- docker pull openhpi/co_execenv_java:8
|
- docker pull openhpi/co_execenv_java:8-antlr
|
||||||
script:
|
script:
|
||||||
- rspec --format progress
|
- rspec --format progress
|
||||||
coverage: '/\(\d+.\d+\%\) covered/'
|
coverage: '/\(\d+.\d+\%\) covered/'
|
||||||
|
@ -9,6 +9,7 @@ describe ExecutionEnvironmentsController do
|
|||||||
before do
|
before do
|
||||||
allow(controller).to receive(:current_user).and_return(user)
|
allow(controller).to receive(:current_user).and_return(user)
|
||||||
allow(controller).to receive(:sync_to_runner_management).and_return(nil)
|
allow(controller).to receive(:sync_to_runner_management).and_return(nil)
|
||||||
|
allow(Runner.strategy_class).to receive(:available_images).and_return([])
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
|
@ -37,7 +37,7 @@ FactoryBot.define do
|
|||||||
created_by_teacher
|
created_by_teacher
|
||||||
default_memory_limit
|
default_memory_limit
|
||||||
default_cpu_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 }
|
file_type { association :dot_java, user: user }
|
||||||
help
|
help
|
||||||
name { 'Java 8' }
|
name { 'Java 8' }
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'Authorization' do
|
describe 'Authorization' do
|
||||||
|
before { allow(Runner.strategy_class).to receive(:available_images).and_return([]) }
|
||||||
|
|
||||||
context 'when being an admin' do
|
context 'when being an admin' do
|
||||||
let(:user) { FactoryBot.create(:admin) }
|
let(:user) { FactoryBot.create(:admin) }
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ describe DockerClient do
|
|||||||
let(:workspace_path) { WORKSPACE_PATH }
|
let(:workspace_path) { WORKSPACE_PATH }
|
||||||
|
|
||||||
before do
|
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
|
described_class.initialize_environment
|
||||||
allow(described_class).to receive(:container_creation_options).and_wrap_original do |original_method, *args, &block|
|
allow(described_class).to receive(:container_creation_options).and_wrap_original do |original_method, *args, &block|
|
||||||
result = original_method.call(*args, &block)
|
result = original_method.call(*args, &block)
|
||||||
@ -69,6 +71,10 @@ describe DockerClient do
|
|||||||
describe '.create_container' do
|
describe '.create_container' do
|
||||||
let(:create_container) { described_class.create_container(execution_environment) }
|
let(:create_container) { described_class.create_container(execution_environment) }
|
||||||
|
|
||||||
|
after do
|
||||||
|
FileUtils.rm_rf(workspace_path)
|
||||||
|
end
|
||||||
|
|
||||||
it 'uses the correct Docker image' do
|
it 'uses the correct Docker image' do
|
||||||
expect(described_class).to receive(:find_image_by_tag).with(execution_environment.docker_image).and_call_original
|
expect(described_class).to receive(:find_image_by_tag).with(execution_environment.docker_image).and_call_original
|
||||||
container = create_container
|
container = create_container
|
||||||
@ -425,7 +431,7 @@ describe DockerClient do
|
|||||||
|
|
||||||
it "returns the container's output" do
|
it "returns the container's output" do
|
||||||
expect(send_command[:stderr]).to be_blank
|
expect(send_command[:stderr]).to be_blank
|
||||||
expect(send_command[:stdout]).to start_with('root')
|
expect(send_command[:stdout]).to start_with('user')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a corresponding status' do
|
it 'returns a corresponding status' do
|
||||||
|
Reference in New Issue
Block a user