Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f199ac77
Commit
f199ac77
authored
Apr 26, 2021
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for AND operator and refactor specs a little
parent
91ce444c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
spec/lib/gitlab/usage/metrics/aggregates/aggregate_spec.rb
spec/lib/gitlab/usage/metrics/aggregates/aggregate_spec.rb
+19
-10
No files found.
spec/lib/gitlab/usage/metrics/aggregates/aggregate_spec.rb
View file @
f199ac77
...
@@ -65,6 +65,15 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Aggregate, :clean_gitlab_redi
...
@@ -65,6 +65,15 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Aggregate, :clean_gitlab_redi
end
end
context
'there are aggregated metrics defined'
do
context
'there are aggregated metrics defined'
do
let
(
:aggregated_metrics
)
do
[
aggregated_metric
(
name:
"gmau_1"
,
source:
datasource
,
time_frame:
time_frame
,
operator:
operator
)
]
end
let
(
:results
)
{
{
'gmau_1'
=>
5
}
}
let
(
:params
)
{
{
start_date:
start_date
,
end_date:
end_date
,
recorded_at:
recorded_at
}
}
before
do
before
do
allow_next_instance_of
(
described_class
)
do
|
instance
|
allow_next_instance_of
(
described_class
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:aggregated_metrics
).
and_return
(
aggregated_metrics
)
allow
(
instance
).
to
receive
(
:aggregated_metrics
).
and_return
(
aggregated_metrics
)
...
@@ -72,23 +81,23 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Aggregate, :clean_gitlab_redi
...
@@ -72,23 +81,23 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Aggregate, :clean_gitlab_redi
end
end
context
'with OR operator'
do
context
'with OR operator'
do
let
(
:aggregated_metrics
)
do
let
(
:operator
)
{
'OR'
}
[
aggregated_metric
(
name:
"gmau_1"
,
source:
datasource
,
time_frame:
time_frame
,
operator:
"OR"
)
]
end
it
'returns the number of unique events occurred for any metric in aggregate'
,
:aggregate_failures
do
it
'returns the number of unique events occurred for any metric in aggregate'
,
:aggregate_failures
do
results
=
{
'gmau_1'
=>
5
}
params
=
{
start_date:
start_date
,
end_date:
end_date
,
recorded_at:
recorded_at
}
expect
(
namespace
::
SOURCES
[
datasource
]).
to
receive
(
:calculate_metrics_union
).
with
(
params
.
merge
(
metric_names:
%w[event1 event2 event3]
)).
and_return
(
5
)
expect
(
namespace
::
SOURCES
[
datasource
]).
to
receive
(
:calculate_metrics_union
).
with
(
params
.
merge
(
metric_names:
%w[event1 event2 event3]
)).
and_return
(
5
)
expect
(
aggregated_metrics_data
).
to
eq
(
results
)
expect
(
aggregated_metrics_data
).
to
eq
(
results
)
end
end
end
end
context
'with AND operator'
do
let
(
:operator
)
{
'AND'
}
it
'returns the number of unique events occurred for any metric in aggregate'
,
:aggregate_failures
do
expect
(
namespace
::
SOURCES
[
datasource
]).
to
receive
(
:calculate_metrics_intersections
).
with
(
params
.
merge
(
metric_names:
%w[event1 event2 event3]
)).
and_return
(
5
)
expect
(
aggregated_metrics_data
).
to
eq
(
results
)
end
end
context
'hidden behind feature flag'
do
context
'hidden behind feature flag'
do
let
(
:enabled_feature_flag
)
{
'test_ff_enabled'
}
let
(
:enabled_feature_flag
)
{
'test_ff_enabled'
}
let
(
:disabled_feature_flag
)
{
'test_ff_disabled'
}
let
(
:disabled_feature_flag
)
{
'test_ff_disabled'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment