diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 00:10:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 00:10:16 +0300 |
commit | 039b920db38c464de624710acec581be5a0eb961 (patch) | |
tree | 77eb43daaa9b25b6f8673433faf2e809992474a6 /spec/workers/ci | |
parent | 042cd704b8177e7997af4a2ca90967d3178ccc3f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/delete_unit_tests_worker_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/workers/ci/delete_unit_tests_worker_spec.rb b/spec/workers/ci/delete_unit_tests_worker_spec.rb new file mode 100644 index 00000000000..ff2575b19c1 --- /dev/null +++ b/spec/workers/ci/delete_unit_tests_worker_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::DeleteUnitTestsWorker do + let(:worker) { described_class.new } + + describe '#perform' do + it 'executes a service' do + expect_next_instance_of(Ci::DeleteUnitTestsService) do |instance| + expect(instance).to receive(:execute) + end + + worker.perform + end + end + + it_behaves_like 'an idempotent worker' do + let!(:unit_test_1) { create(:ci_unit_test) } + let!(:unit_test_2) { create(:ci_unit_test) } + let!(:unit_test_1_recent_failure) { create(:ci_unit_test_failure, unit_test: unit_test_1) } + let!(:unit_test_2_old_failure) { create(:ci_unit_test_failure, unit_test: unit_test_2, failed_at: 15.days.ago) } + + it 'only deletes old unit tests and their failures' do + subject + + expect(unit_test_1.reload).to be_persisted + expect(unit_test_1_recent_failure.reload).to be_persisted + expect(Ci::UnitTest.find_by(id: unit_test_2.id)).to be_nil + expect(Ci::UnitTestFailure.find_by(id: unit_test_2_old_failure.id)).to be_nil + end + end +end |