diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/workers/ci/test_failure_history_worker_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/workers/ci/test_failure_history_worker_spec.rb')
-rw-r--r-- | spec/workers/ci/test_failure_history_worker_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/workers/ci/test_failure_history_worker_spec.rb b/spec/workers/ci/test_failure_history_worker_spec.rb new file mode 100644 index 00000000000..d2896c08209 --- /dev/null +++ b/spec/workers/ci/test_failure_history_worker_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Ci::TestFailureHistoryWorker do + describe '#perform' do + subject(:perform) { described_class.new.perform(pipeline_id) } + + context 'when pipeline exists' do + let(:pipeline) { create(:ci_pipeline) } + let(:pipeline_id) { pipeline.id } + + it 'executes test failure history service' do + expect_next_instance_of(::Ci::TestFailureHistoryService) do |service| + expect(service).to receive(:execute) + end + + perform + end + end + + context 'when pipeline does not exist' do + let(:pipeline_id) { non_existing_record_id } + + it 'does not execute test failure history service' do + expect(Ci::TestFailureHistoryService).not_to receive(:new) + + perform + end + end + end + + include_examples 'an idempotent worker' do + let(:pipeline) { create(:ci_pipeline) } + let(:job_args) { [pipeline.id] } + + it 'tracks test failures' do + # The test report has 2 test case failures + create(:ci_build, :failed, :test_reports, pipeline: pipeline, project: pipeline.project) + + subject + + expect(Ci::TestCase.count).to eq(2) + expect(Ci::TestCaseFailure.count).to eq(2) + end + end +end |