2019-11-21 04:06:16 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-12 05:52:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Git::RemoteMirror do
|
2018-11-12 05:52:48 -05:00
|
|
|
describe '#update' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:repository) { project.repository }
|
2021-06-16 11:10:08 -04:00
|
|
|
let(:url) { 'https://example.com' }
|
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
|
|
|
|
2021-08-12 08:11:05 -04:00
|
|
|
subject(:remote_mirror) { described_class.new(repository, url, **options) }
|
2018-11-12 05:52:48 -05:00
|
|
|
|
2021-08-12 08:11:05 -04:00
|
|
|
it 'delegates to the Gitaly client' do
|
|
|
|
expect(repository.gitaly_remote_client)
|
|
|
|
.to receive(:update_remote_mirror)
|
|
|
|
.with(url, ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS', keep_divergent_refs: true)
|
2018-11-12 05:52:48 -05:00
|
|
|
|
2021-08-12 08:11:05 -04:00
|
|
|
remote_mirror.update # rubocop:disable Rails/SaveBang
|
2018-11-12 05:52:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'wraps gitaly errors' do
|
|
|
|
expect(repository.gitaly_remote_client)
|
|
|
|
.to receive(:update_remote_mirror)
|
|
|
|
.and_raise(StandardError)
|
|
|
|
|
2020-09-23 11:10:14 -04:00
|
|
|
expect { remote_mirror.update }.to raise_error(StandardError) # rubocop:disable Rails/SaveBang
|
2018-11-12 05:52:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|