debian-mirror-gitlab/spec/lib/gitlab/tracking/destinations/snowplow_micro_spec.rb

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

77 lines
1.8 KiB
Ruby
Raw Permalink Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Tracking::Destinations::SnowplowMicro do
include StubENV
2022-08-13 15:12:31 +05:30
let(:snowplow_micro_settings) do
{
enabled: true,
address: address
}
end
let(:address) { "gdk.test:9091" }
2021-12-11 22:18:48 +05:30
before do
allow(Rails.env).to receive(:development?).and_return(true)
end
describe '#hostname' do
2022-08-13 15:12:31 +05:30
context 'when snowplow_micro config is set' do
let(:address) { '127.0.0.1:9091' }
2021-12-11 22:18:48 +05:30
before do
2022-08-13 15:12:31 +05:30
stub_config(snowplow_micro: snowplow_micro_settings)
2021-12-11 22:18:48 +05:30
end
2022-08-13 15:12:31 +05:30
it 'returns proper URI' do
expect(subject.hostname).to eq('127.0.0.1:9091')
expect(subject.uri.scheme).to eq('http')
end
context 'when gitlab config has https scheme' do
before do
stub_config_setting(https: true)
end
it 'returns proper URI' do
expect(subject.hostname).to eq('127.0.0.1:9091')
expect(subject.uri.scheme).to eq('https')
end
2021-12-11 22:18:48 +05:30
end
end
2022-08-13 15:12:31 +05:30
context 'when snowplow_micro config is not set' do
2021-12-11 22:18:48 +05:30
before do
2023-07-09 08:55:56 +05:30
allow(Gitlab.config).to receive(:snowplow_micro).and_raise(GitlabSettings::MissingSetting)
2021-12-11 22:18:48 +05:30
end
2022-08-27 11:52:29 +05:30
it 'returns localhost hostname' do
expect(subject.hostname).to eq('localhost:9090')
2021-12-11 22:18:48 +05:30
end
end
end
2022-01-26 12:08:38 +05:30
describe '#options' do
let_it_be(:group) { create :group }
before do
2022-08-13 15:12:31 +05:30
stub_config(snowplow_micro: snowplow_micro_settings)
2022-01-26 12:08:38 +05:30
end
it 'includes protocol with the correct value' do
expect(subject.options(group)[:protocol]).to eq 'http'
end
it 'includes port with the correct value' do
expect(subject.options(group)[:port]).to eq 9091
end
it 'includes forceSecureTracker with value false' do
expect(subject.options(group)[:forceSecureTracker]).to eq false
end
end
2021-12-11 22:18:48 +05:30
end