diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-17 13:21:46 +0000 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-24 19:02:51 +0100 |
commit | 29fa930bafaf258754f90809fa317e22f4a3a128 (patch) | |
tree | 5d16355e752a02cbd74c4e2f93093d83444dd182 /spec | |
parent | a403011e4f7adae339a3a8584e22a75f4872c3c5 (diff) | |
download | gitlab-ce-29fa930bafaf258754f90809fa317e22f4a3a128.tar.gz |
Migrate .batch_lfs_pointers to Gitalyfeature/migrate-get-lfs-ptrs-to-gitaly
Closes gitaly#921
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/blob_spec.rb | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 8706c89c147..168207552ff 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -260,29 +260,42 @@ describe Gitlab::Git::Blob, seed_helper: true do ) end - it 'returns a list of Gitlab::Git::Blob' do - blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id]) + shared_examples 'fetching batch of LFS pointers' do + it 'returns a list of Gitlab::Git::Blob' do + blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id]) - expect(blobs.count).to eq(1) - expect(blobs).to all( be_a(Gitlab::Git::Blob) ) - end + expect(blobs.count).to eq(1) + expect(blobs).to all( be_a(Gitlab::Git::Blob) ) + end - it 'silently ignores tree objects' do - blobs = described_class.batch_lfs_pointers(repository, [tree_object.oid]) + it 'silently ignores tree objects' do + blobs = described_class.batch_lfs_pointers(repository, [tree_object.oid]) - expect(blobs).to eq([]) - end + expect(blobs).to eq([]) + end + + it 'silently ignores non lfs objects' do + blobs = described_class.batch_lfs_pointers(repository, [non_lfs_blob.id]) - it 'silently ignores non lfs objects' do - blobs = described_class.batch_lfs_pointers(repository, [non_lfs_blob.id]) + expect(blobs).to eq([]) + end + + it 'avoids loading large blobs into memory' do + # This line could call `lookup` on `repository`, so do here before mocking. + non_lfs_blob_id = non_lfs_blob.id + + expect(repository).not_to receive(:lookup) - expect(blobs).to eq([]) + described_class.batch_lfs_pointers(repository, [non_lfs_blob_id]) + end end - it 'avoids loading large blobs into memory' do - expect(repository).not_to receive(:lookup) + context 'when Gitaly batch_lfs_pointers is enabled' do + it_behaves_like 'fetching batch of LFS pointers' + end - described_class.batch_lfs_pointers(repository, [non_lfs_blob.id]) + context 'when Gitaly batch_lfs_pointers is disabled', :disable_gitaly do + it_behaves_like 'fetching batch of LFS pointers' end end |