Fix tests for Runner#attach_to_execution

These tests were blocking because of the newly introduced
EventLoop. The messages sent to the EventLoop are now mocked
and the EventLoop isn't blocking anymore in the tests.
This commit is contained in:
Felix Auringer
2021-07-22 09:09:38 +02:00
committed by Sebastian Serth
parent c7369366d5
commit c8e1a0bbcb
3 changed files with 7 additions and 2 deletions

View File

@ -264,7 +264,8 @@ describe Runner::Strategy::DockerContainerPool do
# TODO: add tests here
let(:command) { 'ls' }
let(:action) { -> { container_pool.attach_to_execution(command) } }
let(:event_loop) { Runner::EventLoop.new }
let(:action) { -> { container_pool.attach_to_execution(command, event_loop) } }
let(:websocket_url) { 'ws://ws.example.com/path/to/websocket' }
end
end

View File

@ -292,7 +292,8 @@ describe Runner::Strategy::Poseidon do
# TODO: add tests here
let(:command) { 'ls' }
let(:action) { -> { poseidon.attach_to_execution(command) } }
let(:event_loop) { Runner::EventLoop.new }
let(:action) { -> { poseidon.attach_to_execution(command, event_loop) } }
let(:websocket_url) { 'ws://ws.example.com/path/to/websocket' }
end
end

View File

@ -62,10 +62,13 @@ describe Runner do
describe '#attach to execution' do
let(:runner) { described_class.create }
let(:command) { 'ls' }
let(:event_loop) { instance_double(Runner::EventLoop) }
before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id)
allow(strategy_class).to receive(:new).and_return(strategy)
allow(event_loop).to receive(:wait)
allow(Runner::EventLoop).to receive(:new).and_return(event_loop)
end
it 'delegates to its strategy' do