Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb')
-rw-r--r--spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb27
1 files changed, 25 insertions, 2 deletions
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