From b9fe665d2539f53fb86771383e18f9045db52414 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 14 Mar 2022 19:45:29 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-8-stable-ee --- .../cleanup/orphan_job_artifact_files_spec.rb | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'spec/lib') diff --git a/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb b/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb index b5adb603dab..e6ef2d8a541 100644 --- a/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb +++ b/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb @@ -34,10 +34,33 @@ RSpec.describe Gitlab::Cleanup::OrphanJobArtifactFiles do cleanup.run! end - it 'finds artifacts on disk' do + it 'finds job artifacts on disk' do artifact = create(:ci_job_artifact, :archive) + artifact_directory = artifact.file.relative_path.to_s.split('/')[0...6].join('/') + + cleaned = [] + + expect(cleanup).to receive(:find_artifacts).and_wrap_original do |original_method, *args, &block| + original_method.call(*args) { |dir| cleaned << dir } + end + + cleanup.run! + + expect(cleaned).to include(/#{artifact_directory}/) + end + + it 'does not find pipeline artifacts on disk' do + artifact = create(:ci_pipeline_artifact, :with_coverage_report) + # using 0...6 to match the -min/maxdepth 6 strictly, since this is one directory + # deeper than job artifacts, and .dirname would not match + artifact_directory = artifact.file.relative_path.to_s.split('/')[0...6].join('/') + + expect(cleanup).to receive(:find_artifacts).and_wrap_original do |original_method, *args, &block| + # this can either _not_ yield at all, or yield with any other file + # except the one that we're explicitly excluding + original_method.call(*args) { |path| expect(path).not_to match(artifact_directory) } + end - expect(cleanup).to receive(:find_artifacts).and_yield(artifact.file.path) cleanup.run! end -- cgit v1.2.1