diff options
author | Nick Thomas <nick@gitlab.com> | 2018-03-06 18:46:36 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-03-07 17:28:15 +0000 |
commit | 4419d7ea1fa780066016c9527b96dba4f15d3f61 (patch) | |
tree | 3c1211d1558ff0b40c1801ec28bea78ff9636986 /spec/lib | |
parent | 98c8c90e92f8f0407bf048d42ff5e4d76ce57ba0 (diff) | |
download | gitlab-ce-4419d7ea1fa780066016c9527b96dba4f15d3f61.tar.gz |
Implement foreground verification of CI artifacts43949-verify-job-artifacts
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/verify/job_artifacts_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/verify/job_artifacts_spec.rb b/spec/lib/gitlab/verify/job_artifacts_spec.rb new file mode 100644 index 00000000000..ec490bdfde2 --- /dev/null +++ b/spec/lib/gitlab/verify/job_artifacts_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Gitlab::Verify::JobArtifacts do + include GitlabVerifyHelpers + + it_behaves_like 'Gitlab::Verify::BatchVerifier subclass' do + let!(:objects) { create_list(:ci_job_artifact, 3, :archive) } + end + + describe '#run_batches' do + let(:failures) { collect_failures } + let(:failure) { failures[artifact] } + + let!(:artifact) { create(:ci_job_artifact, :archive, :correct_checksum) } + + it 'passes artifacts with the correct file' do + expect(failures).to eq({}) + end + + it 'fails artifacts with a missing file' do + FileUtils.rm_f(artifact.file.path) + + expect(failures.keys).to contain_exactly(artifact) + expect(failure).to be_a(Errno::ENOENT) + expect(failure.to_s).to include(artifact.file.path) + end + + it 'fails artifacts with a mismatched checksum' do + File.truncate(artifact.file.path, 0) + + expect(failures.keys).to contain_exactly(artifact) + expect(failure.to_s).to include('Checksum mismatch') + end + end +end |