Add Geo::RepositoriesChangedEventStore

parent eb05dca4
module Geo
class RepositoriesChangedEventStore < EventStore
self.event_type = :repositories_changed_event
attr_reader :geo_node
def initialize(geo_node)
@geo_node = geo_node
end
private
def build_event
Geo::RepositoriesChangedEvent.new(geo_node: geo_node)
end
def log_error(message, error)
Gitlab::Geo::Logger.error(
class: self.class.name,
message: message,
error: error,
geo_node_id: geo_node.id,
geo_node_url: geo_node.url)
end
end
end
require 'spec_helper'
describe Geo::RepositoriesChangedEventStore do
let(:geo_node) { create(:geo_node) }
subject { described_class.new(geo_node) }
describe '#create' do
it 'does not create an event when not running on a primary node' do
allow(Gitlab::Geo).to receive(:primary?) { false }
expect { subject.create }.not_to change(Geo::RepositoriesChangedEvent, :count)
end
it 'creates a repositories changed event when running on a primary node' do
allow(Gitlab::Geo).to receive(:primary?) { true }
expect { subject.create }.to change(Geo::RepositoriesChangedEvent, :count).by(1)
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