debian-mirror-gitlab/spec/lib/gitlab/git/remote_mirror_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
1 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2019-02-15 15:39:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Git::RemoteMirror do
2019-02-15 15:39:39 +05:30
describe '#update' do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
2021-09-04 01:27:46 +05:30
let(:url) { 'https://example.com' }
2020-04-22 19:07:51 +05:30
let(:options) { { only_branches_matching: ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS', keep_divergent_refs: true } }
2019-02-15 15:39:39 +05:30
2021-10-27 15:23:28 +05:30
subject(:remote_mirror) { described_class.new(repository, url, **options) }
2019-02-15 15:39:39 +05:30
2021-10-27 15:23:28 +05:30
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)
2019-02-15 15:39:39 +05:30
2021-10-27 15:23:28 +05:30
remote_mirror.update # rubocop:disable Rails/SaveBang
2019-02-15 15:39:39 +05:30
end
it 'wraps gitaly errors' do
expect(repository.gitaly_remote_client)
.to receive(:update_remote_mirror)
.and_raise(StandardError)
2021-01-03 14:25:43 +05:30
expect { remote_mirror.update }.to raise_error(StandardError) # rubocop:disable Rails/SaveBang
2019-02-15 15:39:39 +05:30
end
end
end