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:
authorKamil Trzciński <ayufan@ayufan.eu>2018-04-03 17:19:26 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2018-04-03 17:19:26 +0300
commit77a6afd569243e479499231c16c5e72e24707f0d (patch)
tree5cfe4615520c1f08cc064d587192a97911a6b941 /spec/services/projects
parentbe1523c1ba9fa439a2525a1b18179a419ecb6b2d (diff)
parenta26ee804d01912d49d982dfbde8e5fe1c198e04f (diff)
Merge branch 'fix/sm/fix-wrong-error-handling-in-update-page-service' into 'master'
Fix wrong error handling in update page service Closes #44817 See merge request gitlab-org/gitlab-ce!18098
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/update_pages_service_spec.rb40
1 files changed, 37 insertions, 3 deletions
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index 934106627a9..dd31a677dfe 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -87,7 +87,8 @@ describe Projects::UpdatePagesService do
it 'fails for empty file fails' do
build.update_attributes(legacy_artifacts_file: empty_file)
- expect(execute).not_to eq(:success)
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
end
end
end
@@ -159,7 +160,8 @@ describe Projects::UpdatePagesService do
it 'fails for empty file fails' do
build.job_artifacts_archive.update_attributes(file: empty_file)
- expect(execute).not_to eq(:success)
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
end
context 'when timeout happens by DNS error' do
@@ -172,7 +174,39 @@ describe Projects::UpdatePagesService do
expect { execute }.to raise_error(SocketError)
build.reload
- expect(build.artifacts?).to eq(true)
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_truthy
+ end
+ end
+
+ context 'when failed to extract zip artifacts' do
+ before do
+ allow_any_instance_of(described_class)
+ .to receive(:extract_zip_archive!)
+ .and_raise(Projects::UpdatePagesService::FailedToExtractError)
+ end
+
+ it 'raises an error' do
+ expect { execute }
+ .to raise_error(Projects::UpdatePagesService::FailedToExtractError)
+
+ build.reload
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_truthy
+ end
+ end
+
+ context 'when missing artifacts metadata' do
+ before do
+ allow(build).to receive(:artifacts_metadata?).and_return(false)
+ end
+
+ it 'does not raise an error and remove artifacts as failed job' do
+ execute
+
+ build.reload
+ expect(deploy_status).to be_failed
+ expect(build.artifacts?).to be_falsey
end
end
end