Commit 62534363 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Raise error when clone_url_prefix is nil and add specs

parent 4ed9c9f9
module Geo
# The clone_url_prefix is used to build URLs for the Geo synchronization
# If this is missing from the primary node we raise this exception
EmptyCloneUrlPrefixError = Class.new(StandardError)
class BaseSyncService
class << self
attr_accessor :type
......@@ -71,7 +75,9 @@ module Geo
end
def primary_ssh_path_prefix
@primary_ssh_path_prefix ||= Gitlab::Geo.primary_node.clone_url_prefix
@primary_ssh_path_prefix ||= Gitlab::Geo.primary_node.clone_url_prefix.tap do |prefix|
raise EmptyCloneUrlPrefixError, 'Missing clone_url_prefix in the primary node' unless prefix.present?
end
end
def log(message)
......
require 'spec_helper'
describe Geo::BaseSyncService, services: true do
let(:project) { double('project')}
subject { described_class.new(project) }
describe '#primary_ssh_path_prefix' do
let!(:primary_node) { create(:geo_node, :primary, host: 'primary-geo-node') }
it 'raises exception when clone_url_prefix is nil' do
allow_any_instance_of(GeoNode).to receive(:clone_url_prefix) { nil }
expect { subject.send(:primary_ssh_path_prefix) }.to raise_error Geo::EmptyCloneUrlPrefixError
end
it 'returns the prefix defined in the primary node' do
expect { subject.send(:primary_ssh_path_prefix) }.not_to raise_error
expect(subject.send(:primary_ssh_path_prefix)).to eq('git@localhost:')
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment