diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-06-06 13:01:09 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-06-12 13:58:01 -0700 |
commit | 2e114a6744e76fc2ecea20c4733d95c439d73aaa (patch) | |
tree | 6f6b67e78e5d0169b50a3eab0597525c954b5d82 | |
parent | b3ecfb68c8f0acd849e576e9bd7b2fb613d9a231 (diff) | |
download | gitlab-ce-2e114a6744e76fc2ecea20c4733d95c439d73aaa.tar.gz |
Support verifying remote job artifacts
-rw-r--r-- | lib/gitlab/verify/job_artifacts.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/verify/job_artifacts_spec.rb | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/gitlab/verify/job_artifacts.rb b/lib/gitlab/verify/job_artifacts.rb index afee3b84268..319c0d92e73 100644 --- a/lib/gitlab/verify/job_artifacts.rb +++ b/lib/gitlab/verify/job_artifacts.rb @@ -26,6 +26,10 @@ module Gitlab def actual_checksum(artifact) Digest::SHA256.file(artifact.file.path).hexdigest end + + def remote_object_exists?(artifact) + artifact.file && artifact.file.exists? + end end end end diff --git a/spec/lib/gitlab/verify/job_artifacts_spec.rb b/spec/lib/gitlab/verify/job_artifacts_spec.rb index ec490bdfde2..e2bd9bf3c62 100644 --- a/spec/lib/gitlab/verify/job_artifacts_spec.rb +++ b/spec/lib/gitlab/verify/job_artifacts_spec.rb @@ -31,5 +31,25 @@ describe Gitlab::Verify::JobArtifacts do expect(failures.keys).to contain_exactly(artifact) expect(failure.to_s).to include('Checksum mismatch') end + + context 'with remote files' do + before do + stub_artifacts_object_storage + artifact.update!(file_store: ObjectStorage::Store::REMOTE) + end + + it 'passes artifacts in object storage that exist' do + expect_any_instance_of(JobArtifactUploader).to receive(:exists?).and_return(true) + + expect(failures).to eq({}) + end + + it 'fails artifacts in object storage that do not exist' do + expect_any_instance_of(JobArtifactUploader).to receive(:exists?).and_return(false) + + expect(failures.keys).to contain_exactly(artifact) + expect(failure.to_s).to include('Remote object does not exist') + end + end end end |