debian-mirror-gitlab/spec/workers/expire_pipeline_cache_worker_spec.rb

42 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe ExpirePipelineCacheWorker do
2020-03-13 15:44:24 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
2020-01-01 13:55:28 +05:30
2017-08-17 22:00:37 +05:30
subject { described_class.new }
describe '#perform' do
2019-07-31 22:56:46 +05:30
it 'executes the service' do
2020-04-22 19:07:51 +05:30
expect_next_instance_of(Ci::ExpirePipelineCacheService) do |instance|
expect(instance).to receive(:execute).with(pipeline).and_call_original
end
2017-08-17 22:00:37 +05:30
subject.perform(pipeline.id)
end
it "doesn't do anything if the pipeline not exist" do
2019-07-31 22:56:46 +05:30
expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute)
2017-08-17 22:00:37 +05:30
expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
subject.perform(617748)
end
2020-03-13 15:44:24 +05:30
it "doesn't do anything if the pipeline cannot be cached" do
allow_any_instance_of(Ci::Pipeline).to receive(:cacheable?).and_return(false)
expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute)
expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
subject.perform(pipeline.id)
end
2020-04-22 19:07:51 +05:30
it_behaves_like 'an idempotent worker' do
let(:job_args) { [pipeline.id] }
end
2017-08-17 22:00:37 +05:30
end
end