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
2040d70f
Commit
2040d70f
authored
Aug 07, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix regex for key name format
parent
c27be87a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
lib/gitlab/redis/hll.rb
lib/gitlab/redis/hll.rb
+3
-3
spec/lib/gitlab/redis/hll_spec.rb
spec/lib/gitlab/redis/hll_spec.rb
+4
-2
No files found.
lib/gitlab/redis/hll.rb
View file @
2040d70f
...
...
@@ -2,9 +2,9 @@
module
Gitlab
module
Redis
KeyFormatError
=
Class
.
new
(
StandardError
)
class
HLL
KeyFormatError
=
Class
.
new
(
StandardError
)
def
self
.
count
(
params
)
self
.
new
.
count
(
params
)
end
...
...
@@ -20,7 +20,7 @@ module Gitlab
end
def
add
(
key
:,
value
:,
expiry
:)
unless
%r{
\A
.*
\{
.*
\}
.
*
\z
}
.
match?
(
key
)
unless
%r{
\A
(
\w
|-|:)*
\{\w
*
\}
(
\w
|-|:)
*
\z
}
.
match?
(
key
)
raise
KeyFormatError
.
new
(
"Invalid key format.
#{
key
}
key should have changeable parts in curly braces. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands"
)
end
...
...
spec/lib/gitlab/redis/hll_spec.rb
View file @
2040d70f
...
...
@@ -5,13 +5,15 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Redis
::
HLL
,
:clean_gitlab_redis_shared_state
do
describe
'.add'
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
::
KeyFormatError
)
expect
{
described_class
.
add
(
key:
'test-{metric'
,
value:
1
,
expiry:
1
.
day
)
}.
to
raise_error
(
Gitlab
::
Redis
::
KeyFormatError
)
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
)
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
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