Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0adbb001
Commit
0adbb001
authored
Jun 24, 2019
by
Kyle Brandt
Committed by
Torkel Ödegaard
Jun 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RemoteCache: redis connection string parsing test (#17702)
parent
d0852f06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
pkg/infra/remotecache/redis_storage_test.go
+65
-0
No files found.
pkg/infra/remotecache/redis_storage_test.go
0 → 100644
View file @
0adbb001
package
remotecache
import
(
"fmt"
"testing"
"github.com/stretchr/testify/assert"
redis
"gopkg.in/redis.v2"
)
func
Test_parseRedisConnStr
(
t
*
testing
.
T
)
{
cases
:=
map
[
string
]
struct
{
InputConnStr
string
OutputOptions
*
redis
.
Options
ShouldErr
bool
}{
"all redis options should parse"
:
{
"addr=127.0.0.1:6379,pool_size=100,db=1,password=grafanaRocks"
,
&
redis
.
Options
{
Addr
:
"127.0.0.1:6379"
,
PoolSize
:
100
,
DB
:
1
,
Password
:
"grafanaRocks"
,
Network
:
"tcp"
,
},
false
,
},
"subset of redis options should parse"
:
{
"addr=127.0.0.1:6379,pool_size=100"
,
&
redis
.
Options
{
Addr
:
"127.0.0.1:6379"
,
PoolSize
:
100
,
Network
:
"tcp"
,
},
false
,
},
"trailing comma should err"
:
{
"addr=127.0.0.1:6379,pool_size=100,"
,
nil
,
true
,
},
"invalid key should err"
:
{
"addr=127.0.0.1:6379,puddle_size=100"
,
nil
,
true
,
},
"empty connection string should err"
:
{
""
,
nil
,
true
,
},
}
for
reason
,
testCase
:=
range
cases
{
options
,
err
:=
parseRedisConnStr
(
testCase
.
InputConnStr
)
if
testCase
.
ShouldErr
{
assert
.
Error
(
t
,
err
,
fmt
.
Sprintf
(
"error cases should return non-nil error for test case %v"
,
reason
))
assert
.
Nil
(
t
,
options
,
fmt
.
Sprintf
(
"error cases should return nil for redis options for test case %v"
,
reason
))
continue
}
assert
.
NoError
(
t
,
err
,
reason
)
assert
.
EqualValues
(
t
,
testCase
.
OutputOptions
,
options
,
reason
)
}
}
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