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/services/ci/job_artifacts/delete_service_spec.rb')
-rw-r--r--spec/services/ci/job_artifacts/delete_service_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/services/ci/job_artifacts/delete_service_spec.rb b/spec/services/ci/job_artifacts/delete_service_spec.rb
new file mode 100644
index 00000000000..62a755eb44a
--- /dev/null
+++ b/spec/services/ci/job_artifacts/delete_service_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::JobArtifacts::DeleteService do
+ let_it_be(:build, reload: true) do
+ create(:ci_build, :artifacts, :trace_artifact, artifacts_expire_at: 100.days.from_now)
+ end
+
+ subject(:service) { described_class.new(build) }
+
+ describe '#execute' do
+ it 'is successful' do
+ result = service.execute
+
+ expect(result).to be_success
+ end
+
+ it 'deletes erasable artifacts' do
+ expect { service.execute }.to change { build.job_artifacts.erasable.count }.from(2).to(0)
+ end
+
+ it 'does not delete trace' do
+ expect { service.execute }.not_to change { build.has_trace? }.from(true)
+ end
+
+ context 'when project is undergoing statistics refresh' do
+ before do
+ allow(build.project).to receive(:refreshing_build_artifacts_size?).and_return(true)
+ end
+
+ it 'logs a warning' do
+ expect(Gitlab::ProjectStatsRefreshConflictsLogger)
+ .to receive(:warn_artifact_deletion_during_stats_refresh)
+ .with(method: 'Ci::JobArtifacts::DeleteService#execute', project_id: build.project_id)
+
+ service.execute
+ end
+ end
+ end
+end