diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-05-02 10:12:15 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-05-07 15:37:49 +0200 |
commit | 713c7fa9a56fbbe301fb21b36fc9002aee0901e8 (patch) | |
tree | ca2f054016341f0353035823568e936a85c7460b /spec/lib | |
parent | 40655a48f13efb3a0a18f0b0bc4727c786df6a77 (diff) | |
download | gitlab-ce-713c7fa9a56fbbe301fb21b36fc9002aee0901e8.tar.gz |
Client implementation GetRawChanges
Part of https://gitlab.com/gitlab-org/gitaly/issues/1138
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 60 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/repository_service_spec.rb | 11 |
2 files changed, 46 insertions, 25 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 9924641f829..9f091975959 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1068,41 +1068,51 @@ describe Gitlab::Git::Repository, seed_helper: true do end describe '#raw_changes_between' do - let(:old_rev) { } - let(:new_rev) { } - let(:changes) { repository.raw_changes_between(old_rev, new_rev) } + shared_examples 'raw changes' do + let(:old_rev) { } + let(:new_rev) { } + let(:changes) { repository.raw_changes_between(old_rev, new_rev) } - context 'initial commit' do - let(:old_rev) { Gitlab::Git::BLANK_SHA } - let(:new_rev) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' } + context 'initial commit' do + let(:old_rev) { Gitlab::Git::BLANK_SHA } + let(:new_rev) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' } - it 'returns the changes' do - expect(changes).to be_present - expect(changes.size).to eq(3) + it 'returns the changes' do + expect(changes).to be_present + expect(changes.size).to eq(3) + end end - end - context 'with an invalid rev' do - let(:old_rev) { 'foo' } - let(:new_rev) { 'bar' } + context 'with an invalid rev' do + let(:old_rev) { 'foo' } + let(:new_rev) { 'bar' } - it 'returns an error' do - expect { changes }.to raise_error(Gitlab::Git::Repository::GitError) + it 'returns an error' do + expect { changes }.to raise_error(Gitlab::Git::Repository::GitError) + end end - end - context 'with valid revs' do - let(:old_rev) { 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6' } - let(:new_rev) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' } + context 'with valid revs' do + let(:old_rev) { 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6' } + let(:new_rev) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' } - it 'returns the changes' do - expect(changes.size).to eq(9) - expect(changes.first.operation).to eq(:modified) - expect(changes.first.new_path).to eq('.gitmodules') - expect(changes.last.operation).to eq(:added) - expect(changes.last.new_path).to eq('files/lfs/picture-invalid.png') + it 'returns the changes' do + expect(changes.size).to eq(9) + expect(changes.first.operation).to eq(:modified) + expect(changes.first.new_path).to eq('.gitmodules') + expect(changes.last.operation).to eq(:added) + expect(changes.last.new_path).to eq('files/lfs/picture-invalid.png') + end end end + + context 'when gitaly is enabled' do + it_behaves_like 'raw changes' + end + + context 'when gitaly is disabled', :disable_gitaly do + it_behaves_like 'raw changes' + end end describe '#merge_base' do diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb index ecd8657c406..1547d447197 100644 --- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb @@ -167,4 +167,15 @@ describe Gitlab::GitalyClient::RepositoryService do client.create_from_snapshot('http://example.com?wiki=1', 'Custom xyz') end end + + describe '#raw_changes_between' do + it 'sends a create_repository_from_snapshot message' do + expect_any_instance_of(Gitaly::RepositoryService::Stub) + .to receive(:get_raw_changes) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return(double) + + client.raw_changes_between('deadbeef', 'deadpork') + end + end end |