hgitaly_client_spec.rb 947 Bytes
Newer Older
1 2 3 4
# frozen_string_literal: true

require 'spec_helper'

5
RSpec.describe 'HGitaly client connection' do
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  let(:user) { create(:user) }

  let(:actor) { user }
  # of course later on we'll make a hgitaly_project, but that's
  # enough for current tests
  let(:project) { create(:hg_git_project, :hg_repository) }
  let(:repo) { project.repository.raw_repository }
  let(:server_address) do
    url = Gitlab.config.repositories.storages[repo.storage].hgitaly_address
    url.sub(%r{^tcp://|^tls://}, '')
  end

  describe 'testing server' do
    it 'responds correctly to a RPC call' do
      stub = Gitaly::RefService::Stub.new(server_address,
                                          :this_channel_is_insecure)
      request = Gitaly::FindDefaultBranchNameRequest.new(
        repository: repo.gitaly_repository)
      response = stub.find_default_branch_name(request)
      expect(response.name).to eq("refs/heads/branch/default")
    end
  end
end