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
45182200
Commit
45182200
authored
Aug 12, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve add and count tests
parent
041e8877
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
spec/lib/gitlab/redis/hll_spec.rb
spec/lib/gitlab/redis/hll_spec.rb
+18
-10
No files found.
spec/lib/gitlab/redis/hll_spec.rb
View file @
45182200
...
...
@@ -6,22 +6,30 @@ RSpec.describe Gitlab::Redis::HLL, :clean_gitlab_redis_shared_state do
describe
'.add'
do
context
'when checking key format'
do
it
'raise an error when using an invalid key format'
do
expect
{
described_class
.
add
(
key:
'test'
,
value:
1
,
expiry:
1
.
day
)
}.
to
raise_error
(
Gitlab
::
Redis
::
HLL
::
KeyFormatError
)
expect
{
described_class
.
add
(
key:
'test-{metric'
,
value:
1
,
expiry:
1
.
day
)
}.
to
raise_error
(
Gitlab
::
Redis
::
HLL
::
KeyFormatError
)
expect
{
described_class
.
add
(
key:
'test-{metric}}'
,
value:
1
,
expiry:
1
.
day
)
}.
to
raise_error
(
Gitlab
::
Redis
::
HLL
::
KeyFormatError
)
[
'test'
,
'test-{metric'
,
'test-{metric}}'
].
each
do
|
key
|
expect
{
described_class
.
add
(
key:
key
,
value:
1
,
expiry:
1
.
day
)
}.
to
raise_error
(
Gitlab
::
Redis
::
HLL
::
KeyFormatError
)
end
end
it
"doesn't raise error when having correct format"
do
expect
{
described_class
.
add
(
key:
'test-{metric}'
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
expect
{
described_class
.
add
(
key:
'test-{metric}-1'
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
expect
{
described_class
.
add
(
key:
'test:{metric}-1'
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
expect
{
described_class
.
add
(
key:
'2020-216-{project_action}'
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
expect
{
described_class
.
add
(
key:
'i_{analytics}_dev_ops_score-2020-32'
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
[
'test-{metric}'
,
'test-{metric}-1'
,
'test:{metric}-1'
,
'2020-216-{project_action}'
,
'i_{analytics}_dev_ops_score-2020-32'
].
each
do
|
key
|
expect
{
described_class
.
add
(
key:
key
,
value:
1
,
expiry:
1
.
day
)
}.
not_to
raise_error
end
end
end
end
describe
'
counts correct data for expand_vulnerabilities eve
nt'
do
describe
'
.cou
nt'
do
before
do
described_class
.
add
(
key:
'2020-32-{expand_vulnerabilities}'
,
value:
"user_id_1"
,
expiry:
1
.
day
)
described_class
.
add
(
key:
'2020-32-{expand_vulnerabilities}'
,
value:
"user_id_1"
,
expiry:
1
.
day
)
...
...
@@ -47,7 +55,7 @@ RSpec.describe Gitlab::Redis::HLL, :clean_gitlab_redis_shared_state do
expect
(
described_class
.
count
(
keys:
[
'2020-33-{expand_vulnerabilities}'
,
'2020-34-{expand_vulnerabilities}'
])).
to
eq
(
2
)
end
it
'has one distinct user for wee
l
33'
do
it
'has one distinct user for wee
k
33'
do
expect
(
described_class
.
count
(
keys:
[
'2020-33-{expand_vulnerabilities}'
])).
to
eq
(
1
)
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