summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gitaly_client/remote_service_spec.rb
blob: 69c6f054016265fa865b8371f1137cc52871018b (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
27
28
29
30
31
32
33
34
require 'spec_helper'

describe Gitlab::GitalyClient::RemoteService do
  let(:project) { create(:project) }
  let(:storage_name) { project.repository_storage }
  let(:relative_path) { project.disk_path + '.git' }
  let(:remote_name) { 'my-remote' }
  let(:client) { described_class.new(project.repository) }

  describe '#add_remote' do
    let(:url) { 'http://my-repo.git' }
    let(:mirror_refmap) { :all_refs }

    it 'sends an add_remote message' do
      expect_any_instance_of(Gitaly::RemoteService::Stub)
        .to receive(:add_remote)
        .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
        .and_return(double(:add_remote_response))

      client.add_remote(remote_name, url, mirror_refmap)
    end
  end

  describe '#remove_remote' do
    it 'sends an remove_remote message and returns the result value' do
      expect_any_instance_of(Gitaly::RemoteService::Stub)
        .to receive(:remove_remote)
        .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
        .and_return(double(result: true))

      expect(client.remove_remote(remote_name)).to be(true)
    end
  end
end