2017-04-03 09:27:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::GitalyClient, lib: true do
|
2017-05-10 08:18:59 -04:00
|
|
|
describe '.stub' do
|
|
|
|
before { described_class.clear_stubs! }
|
|
|
|
|
2017-04-03 09:27:14 -04:00
|
|
|
context 'when passed a UNIX socket address' do
|
2017-05-10 08:18:59 -04:00
|
|
|
it 'passes the address as-is to GRPC' do
|
2017-04-03 09:27:14 -04:00
|
|
|
address = 'unix:/tmp/gitaly.sock'
|
2017-05-10 08:18:59 -04:00
|
|
|
allow(Gitlab.config.repositories).to receive(:storages).and_return({
|
|
|
|
'default' => { 'gitaly_address' => address }
|
|
|
|
})
|
2017-04-03 09:27:14 -04:00
|
|
|
|
2017-05-10 08:18:59 -04:00
|
|
|
expect(Gitaly::Commit::Stub).to receive(:new).with(address, any_args)
|
2017-04-03 09:27:14 -04:00
|
|
|
|
2017-05-10 08:18:59 -04:00
|
|
|
described_class.stub(:commit, 'default')
|
2017-04-03 09:27:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when passed a TCP address' do
|
|
|
|
it 'strips tcp:// prefix before passing it to GRPC::Core::Channel initializer' do
|
|
|
|
address = 'localhost:9876'
|
|
|
|
prefixed_address = "tcp://#{address}"
|
|
|
|
|
2017-05-10 08:18:59 -04:00
|
|
|
allow(Gitlab.config.repositories).to receive(:storages).and_return({
|
|
|
|
'default' => { 'gitaly_address' => prefixed_address }
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(Gitaly::Commit::Stub).to receive(:new).with(address, any_args)
|
2017-04-03 09:27:14 -04:00
|
|
|
|
2017-05-10 08:18:59 -04:00
|
|
|
described_class.stub(:commit, 'default')
|
2017-04-03 09:27:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|