diff options
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/build_finished_worker_spec.rb | 13 | ||||
-rw-r--r-- | spec/workers/ci/job_artifacts/track_artifact_report_worker_spec.rb | 60 |
2 files changed, 60 insertions, 13 deletions
diff --git a/spec/workers/ci/build_finished_worker_spec.rb b/spec/workers/ci/build_finished_worker_spec.rb index 5ddaabc3938..e8bb3988001 100644 --- a/spec/workers/ci/build_finished_worker_spec.rb +++ b/spec/workers/ci/build_finished_worker_spec.rb @@ -27,19 +27,6 @@ RSpec.describe Ci::BuildFinishedWorker do subject end - context 'when the execute_build_hooks_inline feature flag is disabled' do - before do - stub_feature_flags(execute_build_hooks_inline: false) - end - - it 'uses the BuildHooksWorker' do - expect(build).not_to receive(:execute_hooks) - expect(BuildHooksWorker).to receive(:perform_async).with(build) - - subject - end - end - context 'when build is failed' do before do build.update!(status: :failed) diff --git a/spec/workers/ci/job_artifacts/track_artifact_report_worker_spec.rb b/spec/workers/ci/job_artifacts/track_artifact_report_worker_spec.rb new file mode 100644 index 00000000000..e18539cc6e3 --- /dev/null +++ b/spec/workers/ci/job_artifacts/track_artifact_report_worker_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::JobArtifacts::TrackArtifactReportWorker do + describe '#perform', :clean_gitlab_redis_shared_state do + let_it_be(:group) { create(:group, :private) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:user) { create(:user) } + + let_it_be(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project, user: user) } + + subject(:perform) { described_class.new.perform(pipeline_id) } + + context 'when pipeline is found' do + let(:pipeline_id) { pipeline.id } + + it 'executed service' do + expect_next_instance_of(Ci::JobArtifacts::TrackArtifactReportService) do |instance| + expect(instance).to receive(:execute).with(pipeline) + end + + perform + end + + it_behaves_like 'an idempotent worker' do + let(:job_args) { pipeline_id } + let(:test_event_name) { 'i_testing_test_report_uploaded' } + let(:start_time) { 1.week.ago } + let(:end_time) { 1.week.from_now } + + subject(:idempotent_perform) { perform_multiple(pipeline_id, exec_times: 2) } + + it 'does not try to increment again' do + idempotent_perform + + unique_pipeline_pass = Gitlab::UsageDataCounters::HLLRedisCounter.unique_events( + event_names: test_event_name, + start_date: start_time, + end_date: end_time + ) + expect(unique_pipeline_pass).to eq(1) + end + end + end + + context 'when pipeline is not found' do + let(:pipeline_id) { non_existing_record_id } + + it 'does not execute service' do + allow_next_instance_of(Ci::JobArtifacts::TrackArtifactReportService) do |instance| + expect(instance).not_to receive(:execute) + end + + expect { perform } + .not_to raise_error + end + end + end +end |