diff options
| author | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-05 11:16:26 +0000 |
|---|---|---|
| committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-05 11:16:26 +0000 |
| commit | b7cacaaf4fedd3d9b3b19ea3f1fe3eb585112b88 (patch) | |
| tree | 4f2e1e6405eb72b46cfbcbb1d6e9d06f57269220 /spec/support | |
| parent | d50caa64f8701bdd0520eee5f9e8ad6755e2601b (diff) | |
| parent | 6f945f20b4c3683bc862ebc476bad9331d72784e (diff) | |
| download | gitlab-ce-b7cacaaf4fedd3d9b3b19ea3f1fe3eb585112b88.tar.gz | |
Merge branch 'ee-4862-verify-file-checksums' into 'master'
Foreground verification of uploads and LFS objects
See merge request gitlab-org/gitlab-ce!17402
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/gitlab_verify.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/support/gitlab_verify.rb b/spec/support/gitlab_verify.rb new file mode 100644 index 00000000000..13e2e37624d --- /dev/null +++ b/spec/support/gitlab_verify.rb @@ -0,0 +1,45 @@ +RSpec.shared_examples 'Gitlab::Verify::BatchVerifier subclass' do + describe 'batching' do + let(:first_batch) { objects[0].id..objects[0].id } + let(:second_batch) { objects[1].id..objects[1].id } + let(:third_batch) { objects[2].id..objects[2].id } + + it 'iterates through objects in batches' do + expect(collect_ranges).to eq([first_batch, second_batch, third_batch]) + end + + it 'allows the starting ID to be specified' do + expect(collect_ranges(start: second_batch.first)).to eq([second_batch, third_batch]) + end + + it 'allows the finishing ID to be specified' do + expect(collect_ranges(finish: second_batch.last)).to eq([first_batch, second_batch]) + end + end +end + +module GitlabVerifyHelpers + def collect_ranges(args = {}) + verifier = described_class.new(args.merge(batch_size: 1)) + + collect_results(verifier).map { |range, _| range } + end + + def collect_failures + verifier = described_class.new(batch_size: 1) + + out = {} + + collect_results(verifier).map { |_, failures| out.merge!(failures) } + + out + end + + def collect_results(verifier) + out = [] + + verifier.run_batches { |*args| out << args } + + out + end +end |
