summaryrefslogtreecommitdiff
path: root/spec/services/ci/job_artifacts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-20 09:40:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-20 09:40:42 +0000
commitee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch)
treef8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/services/ci/job_artifacts
parent62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff)
downloadgitlab-ce-ee664acb356f8123f4f6b00b73c1e1cf0866c7fb.tar.gz
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/services/ci/job_artifacts')
-rw-r--r--spec/services/ci/job_artifacts/create_service_spec.rb3
-rw-r--r--spec/services/ci/job_artifacts/delete_service_spec.rb27
2 files changed, 28 insertions, 2 deletions
diff --git a/spec/services/ci/job_artifacts/create_service_spec.rb b/spec/services/ci/job_artifacts/create_service_spec.rb
index a2259f9813b..030ba84951e 100644
--- a/spec/services/ci/job_artifacts/create_service_spec.rb
+++ b/spec/services/ci/job_artifacts/create_service_spec.rb
@@ -182,7 +182,8 @@ RSpec.describe Ci::JobArtifacts::CreateService do
end
context 'with job partitioning' do
- let(:job) { create(:ci_build, project: project, partition_id: 123) }
+ let(:pipeline) { create(:ci_pipeline, project: project, partition_id: 123) }
+ let(:job) { create(:ci_build, pipeline: pipeline) }
it 'sets partition_id on artifacts' do
expect { subject }.to change { Ci::JobArtifact.count }
diff --git a/spec/services/ci/job_artifacts/delete_service_spec.rb b/spec/services/ci/job_artifacts/delete_service_spec.rb
index 62a755eb44a..78e8be48255 100644
--- a/spec/services/ci/job_artifacts/delete_service_spec.rb
+++ b/spec/services/ci/job_artifacts/delete_service_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe Ci::JobArtifacts::DeleteService do
result = service.execute
expect(result).to be_success
+ expect(result[:destroyed_artifacts_count]).to be(2)
end
it 'deletes erasable artifacts' do
@@ -24,7 +25,7 @@ RSpec.describe Ci::JobArtifacts::DeleteService do
expect { service.execute }.not_to change { build.has_trace? }.from(true)
end
- context 'when project is undergoing statistics refresh' do
+ context 'when project is undergoing stats refresh' do
before do
allow(build.project).to receive(:refreshing_build_artifacts_size?).and_return(true)
end
@@ -36,6 +37,30 @@ RSpec.describe Ci::JobArtifacts::DeleteService do
service.execute
end
+
+ it 'returns an error response with the correct message and reason' do
+ result = service.execute
+
+ expect(result).to be_error
+ expect(result[:message]).to be('Action temporarily disabled. ' \
+ 'The project this job belongs to is undergoing stats refresh.')
+ expect(result[:reason]).to be(:project_stats_refresh)
+ end
+ end
+
+ context 'when an error response is received from DestroyBatchService' do
+ before do
+ allow_next_instance_of(Ci::JobArtifacts::DestroyBatchService) do |service|
+ allow(service).to receive(:execute).and_return({ status: :error, message: 'something went wrong' })
+ end
+ end
+
+ it 'returns an error response with the correct message' do
+ result = service.execute
+
+ expect(result).to be_error
+ expect(result[:message]).to be('something went wrong')
+ end
end
end
end