Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/api/ci/helpers/runner_spec.rb')
-rw-r--r--spec/lib/api/ci/helpers/runner_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/api/ci/helpers/runner_spec.rb b/spec/lib/api/ci/helpers/runner_spec.rb
index 06ec0396ab1..62b79c77b4a 100644
--- a/spec/lib/api/ci/helpers/runner_spec.rb
+++ b/spec/lib/api/ci/helpers/runner_spec.rb
@@ -134,4 +134,36 @@ RSpec.describe API::Ci::Helpers::Runner do
.and not_change { success_counter.get(runner_type: 'project_type') }
end
end
+
+ describe '#check_if_backoff_required!' do
+ subject { helper.check_if_backoff_required! }
+
+ let(:backoff_runner) { false }
+
+ before do
+ allow(Gitlab::Database::Migrations::RunnerBackoff::Communicator)
+ .to receive(:backoff_runner?)
+ .and_return(backoff_runner)
+ end
+
+ context 'when migrations are running' do
+ let(:backoff_runner) { true }
+
+ it 'denies requests' do
+ expect(helper).to receive(:too_many_requests!)
+
+ subject
+ end
+ end
+
+ context 'when migrations are not running' do
+ let(:backoff_runner) { false }
+
+ it 'allows requests' do
+ expect(helper).not_to receive(:too_many_requests!)
+
+ subject
+ end
+ end
+ end
end