summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2018-02-01 20:56:41 +0100
committerAhmad Sherif <me@ahmadsherif.com>2018-02-05 17:38:07 +0100
commit2964d5222aa1ce4447561bf5855eef00adf8282e (patch)
tree416f4159fcf888eedd1e042754e679984c0bca3c /spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
parentbfb32b46327576f5b5d4ff3d42198ba4601f1830 (diff)
downloadgitlab-ce-2964d5222aa1ce4447561bf5855eef00adf8282e.tar.gz
Migrate Git::Blob.batch to Gitalyfeature/migrate-blob-batch-to-gitaly
Closes gitaly#985
Diffstat (limited to 'spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb')
-rw-r--r--spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
new file mode 100644
index 00000000000..9db710e759e
--- /dev/null
+++ b/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe Gitlab::GitalyClient::BlobsStitcher do
+ describe 'enumeration' do
+ it 'combines segregated blob messages together' do
+ messages = [
+ OpenStruct.new(oid: 'abcdef1', path: 'path/to/file', size: 1642, revision: 'f00ba7', mode: 0100644, data: "first-line\n"),
+ OpenStruct.new(oid: '', data: 'second-line'),
+ OpenStruct.new(oid: '', data: '', revision: 'f00ba7', path: 'path/to/non-existent/file'),
+ OpenStruct.new(oid: 'abcdef2', path: 'path/to/another-file', size: 2461, revision: 'f00ba8', mode: 0100644, data: "GIF87a\x90\x01".b)
+ ]
+
+ blobs = described_class.new(messages).to_a
+
+ expect(blobs.size).to be(2)
+
+ expect(blobs[0].id).to eq('abcdef1')
+ expect(blobs[0].mode).to eq('100644')
+ expect(blobs[0].name).to eq('file')
+ expect(blobs[0].path).to eq('path/to/file')
+ expect(blobs[0].size).to eq(1642)
+ expect(blobs[0].commit_id).to eq('f00ba7')
+ expect(blobs[0].data).to eq("first-line\nsecond-line")
+ expect(blobs[0].binary?).to be false
+
+ expect(blobs[1].id).to eq('abcdef2')
+ expect(blobs[1].mode).to eq('100644')
+ expect(blobs[1].name).to eq('another-file')
+ expect(blobs[1].path).to eq('path/to/another-file')
+ expect(blobs[1].size).to eq(2461)
+ expect(blobs[1].commit_id).to eq('f00ba8')
+ expect(blobs[1].data).to eq("GIF87a\x90\x01".b)
+ expect(blobs[1].binary?).to be true
+ end
+ end
+end