summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gitaly_client_spec.rb
blob: 55fcf91fb6e9c258dc0b15e3100cc0d1eb0dbd3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'spec_helper'

describe Gitlab::GitalyClient, lib: true do
  describe '.new_channel' do
    context 'when passed a UNIX socket address' do
      it 'passes the address as-is to GRPC::Core::Channel initializer' do
        address = 'unix:/tmp/gitaly.sock'

        expect(GRPC::Core::Channel).to receive(:new).with(address, any_args)

        described_class.new_channel(address)
      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}"

        expect(GRPC::Core::Channel).to receive(:new).with(address, any_args)

        described_class.new_channel(prefixed_address)
      end
    end
  end
end