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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 15:10:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 15:10:44 +0300
commita4068557f4e8f0622798ccf824ac314e2008a57b (patch)
treea3ddbb6c902828009c0e02813339abe88cae9d60 /spec/workers
parentd0a683e342c9e59bec8bb83879f0fc959b79224e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/ci/runners/reconcile_existing_runner_versions_cron_worker_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/workers/ci/runners/reconcile_existing_runner_versions_cron_worker_spec.rb b/spec/workers/ci/runners/reconcile_existing_runner_versions_cron_worker_spec.rb
new file mode 100644
index 00000000000..ab310bffe37
--- /dev/null
+++ b/spec/workers/ci/runners/reconcile_existing_runner_versions_cron_worker_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::Runners::ReconcileExistingRunnerVersionsCronWorker do
+ subject(:worker) { described_class.new }
+
+ describe '#perform' do
+ context 'when scheduled by cronjob' do
+ it 'reschedules itself' do
+ expect(described_class).to(receive(:perform_in).with(a_value_between(0, 12.hours.in_seconds), false))
+ expect(::Ci::Runners::ReconcileExistingRunnerVersionsService).not_to receive(:new)
+
+ worker.perform
+ end
+ end
+
+ context 'when self-scheduled' do
+ include_examples 'an idempotent worker' do
+ subject(:perform) { perform_multiple(false, worker: worker) }
+
+ it 'executes the service' do
+ expect_next_instance_of(Ci::Runners::ReconcileExistingRunnerVersionsService) do |service|
+ expect(service).to receive(:execute).and_return({})
+ end.exactly(worker_exec_times)
+
+ perform
+ end
+ end
+
+ it 'logs the service result' do
+ expect_next_instance_of(Ci::Runners::ReconcileExistingRunnerVersionsService) do |service|
+ expect(service).to receive(:execute).and_return({ some_job_result_key: 'some_value' })
+ end
+
+ worker.perform(false)
+
+ expect(worker.logging_extras).to eq({
+ 'extra.ci_runners_reconcile_existing_runner_versions_cron_worker.some_job_result_key' => 'some_value'
+ })
+ end
+ end
+ end
+end