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
ba4b88e1
Commit
ba4b88e1
authored
Jun 11, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DatabaseMetric specs
parent
50145935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb
...ab/usage/metrics/instrumentations/database_metric_spec.rb
+35
-0
No files found.
spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb
0 → 100644
View file @
ba4b88e1
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Usage
::
Metrics
::
Instrumentations
::
DatabaseMetric
do
subject
do
described_class
.
tap
do
|
m
|
m
.
relation
{
Issue
}
m
.
operation
:count
m
.
start
{
m
.
relation
.
minimum
(
:id
)
}
m
.
finish
{
m
.
relation
.
maximum
(
:id
)
}
end
.
new
(
time_frame:
'all'
)
end
describe
'#value'
do
let_it_be
(
:issue_1
)
{
create
(
:issue
,
id:
314
)
}
let_it_be
(
:issue_2
)
{
create
(
:issue
,
id:
451
)
}
let_it_be
(
:issue_3
)
{
create
(
:issue
,
id:
949
)
}
before
do
allow
(
ActiveRecord
::
Base
.
connection
).
to
receive
(
:transaction_open?
).
and_return
(
false
)
end
it
'calculates a correct result'
do
expect
(
subject
.
value
).
to
eq
(
3
)
end
it
'caches the result of start and finish'
,
:use_clean_rails_redis_caching
do
subject
.
value
expect
(
Rails
.
cache
.
read
(
'metric_instrumentation/issues_minimum_id'
)).
to
eq
(
314
)
expect
(
Rails
.
cache
.
read
(
'metric_instrumentation/issues_maximum_id'
)).
to
eq
(
949
)
end
end
end
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