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/workers/expire_job_cache_worker_spec.rb')
-rw-r--r--spec/workers/expire_job_cache_worker_spec.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb
index eeab304d926..ebca7020ee5 100644
--- a/spec/workers/expire_job_cache_worker_spec.rb
+++ b/spec/workers/expire_job_cache_worker_spec.rb
@@ -6,20 +6,32 @@ describe ExpireJobCacheWorker do
set(:pipeline) { create(:ci_empty_pipeline) }
let(:project) { pipeline.project }
- subject { described_class.new }
-
describe '#perform' do
context 'with a job in the pipeline' do
let(:job) { create(:ci_build, pipeline: pipeline) }
+ let(:job_args) { job.id }
+
+ include_examples 'an idempotent worker' do
+ it 'invalidates Etag caching for the job path' do
+ pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
+ job_path = "/#{project.full_path}/builds/#{job.id}.json"
+
+ spy_store = Gitlab::EtagCaching::Store.new
+
+ allow(Gitlab::EtagCaching::Store).to receive(:new) { spy_store }
- it 'invalidates Etag caching for the job path' do
- pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
- job_path = "/#{project.full_path}/builds/#{job.id}.json"
+ expect(spy_store).to receive(:touch)
+ .exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
+ .with(pipeline_path)
+ .and_call_original
- expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(pipeline_path)
- expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(job_path)
+ expect(spy_store).to receive(:touch)
+ .exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
+ .with(job_path)
+ .and_call_original
- subject.perform(job.id)
+ subject
+ end
end
end
@@ -27,7 +39,7 @@ describe ExpireJobCacheWorker do
it 'does not change the etag store' do
expect(Gitlab::EtagCaching::Store).not_to receive(:new)
- subject.perform(9999)
+ perform_multiple(9999)
end
end
end