From 08ce213c410aa6c6d48fddc2de79accc094564a9 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Mon, 10 Jul 2017 05:43:20 +0200 Subject: Migrate Workhorse SendBlob to Gitaly --- spec/lib/gitlab/workhorse_spec.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'spec/lib') diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 493ff3bb5fb..1bcd0681621 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -317,4 +317,42 @@ describe Gitlab::Workhorse, lib: true do end end end + + describe '.send_git_blob' do + include FakeBlobHelpers + + let(:blob) { fake_blob } + + subject { described_class.send_git_blob(repository, blob) } + + context 'when Gitaly project_raw_show feature is enabled' do + it 'sets the header correctly' do + key, command, params = decode_workhorse_header(subject) + + expect(key).to eq('Gitlab-Workhorse-Send-Data') + expect(command).to eq('git-blob') + expect(params).to eq({ + 'GitalyServer' => { + address: Gitlab::GitalyClient.address(project.repository_storage), + token: Gitlab::GitalyClient.token(project.repository_storage) + }, + 'GetBlobRequest' => { + repository: repository.gitaly_repository.to_h, + oid: blob.id, + limit: -1 + } + }.deep_stringify_keys) + end + end + + context 'when Gitaly project_raw_show feature is disabled', skip_gitaly_mock: true do + it 'sets the header correctly' do + key, command, params = decode_workhorse_header(subject) + + expect(key).to eq('Gitlab-Workhorse-Send-Data') + expect(command).to eq('git-blob') + expect(params).to eq('RepoPath' => repository.path_to_repo, 'BlobId' => blob.id) + end + end + end end -- cgit v1.2.1