2019-11-21 04:06:16 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-12 05:52:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Git::RemoteMirror do
|
|
|
|
describe '#update' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:repository) { project.repository }
|
|
|
|
let(:ref_name) { 'foo' }
|
2020-04-02 11:08:01 -04:00
|
|
|
let(:options) { { only_branches_matching: ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS', keep_divergent_refs: true } }
|
2018-11-12 05:52:48 -05:00
|
|
|
|
|
|
|
subject(:remote_mirror) { described_class.new(repository, ref_name, **options) }
|
|
|
|
|
|
|
|
it 'delegates to the Gitaly client' do
|
|
|
|
expect(repository.gitaly_remote_client)
|
|
|
|
.to receive(:update_remote_mirror)
|
2020-04-02 11:08:01 -04:00
|
|
|
.with(ref_name, ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS', keep_divergent_refs: true)
|
2018-11-12 05:52:48 -05:00
|
|
|
|
|
|
|
remote_mirror.update
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'wraps gitaly errors' do
|
|
|
|
expect(repository.gitaly_remote_client)
|
|
|
|
.to receive(:update_remote_mirror)
|
|
|
|
.and_raise(StandardError)
|
|
|
|
|
|
|
|
expect { remote_mirror.update }.to raise_error(StandardError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|