diff options
Diffstat (limited to 'spec/lib/gitlab/tracking')
-rw-r--r-- | spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/tracking/event_definition_spec.rb | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb b/spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb index ea3c030541f..19b578a4d6d 100644 --- a/spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb +++ b/spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Tracking::Destinations::SnowplowMicro do +RSpec.describe Gitlab::Tracking::Destinations::SnowplowMicro, feature_category: :application_instrumentation do include StubENV let(:snowplow_micro_settings) do @@ -18,6 +18,8 @@ RSpec.describe Gitlab::Tracking::Destinations::SnowplowMicro do allow(Rails.env).to receive(:development?).and_return(true) end + it { is_expected.to delegate_method(:flush).to(:tracker) } + describe '#hostname' do context 'when snowplow_micro config is set' do let(:address) { '127.0.0.1:9091' } diff --git a/spec/lib/gitlab/tracking/event_definition_spec.rb b/spec/lib/gitlab/tracking/event_definition_spec.rb index ab0660147e4..5e41c691da8 100644 --- a/spec/lib/gitlab/tracking/event_definition_spec.rb +++ b/spec/lib/gitlab/tracking/event_definition_spec.rb @@ -35,6 +35,33 @@ RSpec.describe Gitlab::Tracking::EventDefinition do expect { described_class.definitions }.not_to raise_error end + it 'has no duplicated actions in InternalEventTracking events', :aggregate_failures do + definitions_by_action = described_class.definitions + .select { |d| d.category == 'InternalEventTracking' } + .group_by(&:action) + + definitions_by_action.each do |action, definitions| + expect(definitions.size).to eq(1), + "Multiple definitions use the action '#{action}': #{definitions.map(&:path).join(', ')}" + end + end + + it 'has event definitions for all events used in Internal Events metric definitions', :aggregate_failures do + from_metric_definitions = Gitlab::Usage::MetricDefinition.definitions + .values + .select { |m| m.attributes[:data_source] == 'internal_events' } + .flat_map { |m| m.events&.keys } + .compact + .uniq + + event_names = Gitlab::Tracking::EventDefinition.definitions.map { |e| e.attributes[:action] } + + from_metric_definitions.each do |event| + expect(event_names).to include(event), + "Event '#{event}' is used in Internal Events but does not have an event definition yet. Please define it." + end + end + describe '#validate' do using RSpec::Parameterized::TableSyntax |