diff options
author | Robert Speicher <robert@gitlab.com> | 2018-01-24 19:25:30 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-01-24 19:25:30 +0000 |
commit | 8fe314e478e5767c6c351467a85c87ae30d043ea (patch) | |
tree | 6f70980e8faa06be5a60abb92c3d953adfa96754 /spec | |
parent | 956c55e2abf9c9780f37d14d69eb4b53fec4621e (diff) | |
parent | 29fa930bafaf258754f90809fa317e22f4a3a128 (diff) | |
download | gitlab-ce-8fe314e478e5767c6c351467a85c87ae30d043ea.tar.gz |
Merge branch 'feature/migrate-get-lfs-ptrs-to-gitaly' into 'master'
Migrate .batch_lfs_pointers to Gitaly
Closes gitaly#921
See merge request gitlab-org/gitlab-ce!16517
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 |