debian-mirror-gitlab/spec/lib/gitlab/usage/metric_spec.rb

30 lines
1 KiB
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metric do
describe '#definition' do
2021-03-11 19:13:27 +05:30
it 'returns key_path metric definiton' do
expect(described_class.new(key_path: 'uuid').definition).to be_an(Gitlab::Usage::MetricDefinition)
2021-03-08 18:12:59 +05:30
end
end
describe '#unflatten_default_path' do
using RSpec::Parameterized::TableSyntax
2021-03-11 19:13:27 +05:30
where(:key_path, :value, :expected_hash) do
2021-03-08 18:12:59 +05:30
'uuid' | nil | { uuid: nil }
'uuid' | '1111' | { uuid: '1111' }
'counts.issues' | nil | { counts: { issues: nil } }
'counts.issues' | 100 | { counts: { issues: 100 } }
'usage_activity_by_stage.verify.ci_builds' | 100 | { usage_activity_by_stage: { verify: { ci_builds: 100 } } }
end
with_them do
2021-03-11 19:13:27 +05:30
subject { described_class.new(key_path: key_path, value: value).unflatten_key_path }
2021-03-08 18:12:59 +05:30
it { is_expected.to eq(expected_hash) }
end
end
end