From c8e1a0bbcbe08334ac030bfb11c529189af7ab98 Mon Sep 17 00:00:00 2001 From: Felix Auringer <48409110+felixauringer@users.noreply.github.com> Date: Thu, 22 Jul 2021 09:09:38 +0200 Subject: [PATCH] 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. --- spec/lib/runner/strategy/docker_container_pool_spec.rb | 3 ++- spec/lib/runner/strategy/poseidon_spec.rb | 3 ++- spec/models/runner_spec.rb | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/lib/runner/strategy/docker_container_pool_spec.rb b/spec/lib/runner/strategy/docker_container_pool_spec.rb index 26568b6f..9f75e241 100644 --- a/spec/lib/runner/strategy/docker_container_pool_spec.rb +++ b/spec/lib/runner/strategy/docker_container_pool_spec.rb @@ -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 diff --git a/spec/lib/runner/strategy/poseidon_spec.rb b/spec/lib/runner/strategy/poseidon_spec.rb index ef04a6f7..79c4935b 100644 --- a/spec/lib/runner/strategy/poseidon_spec.rb +++ b/spec/lib/runner/strategy/poseidon_spec.rb @@ -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 diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb index 5202d403..4bea42e0 100644 --- a/spec/models/runner_spec.rb +++ b/spec/models/runner_spec.rb @@ -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