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
e8dfbe94
Commit
e8dfbe94
authored
Aug 05, 2018
by
tariq1890
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing bug in url query reader and added test cases
parent
6f1b125c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletions
+50
-1
pkg/util/url.go
+1
-1
pkg/util/url_test.go
+27
-0
pkg/util/validation_test.go
+22
-0
No files found.
pkg/util/url.go
View file @
e8dfbe94
...
...
@@ -10,7 +10,7 @@ type UrlQueryReader struct {
}
func
NewUrlQueryReader
(
urlInfo
*
url
.
URL
)
(
*
UrlQueryReader
,
error
)
{
u
,
err
:=
url
.
ParseQuery
(
urlInfo
.
String
()
)
u
,
err
:=
url
.
ParseQuery
(
urlInfo
.
RawQuery
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/util/url_test.go
View file @
e8dfbe94
...
...
@@ -4,6 +4,7 @@ import (
"testing"
.
"github.com/smartystreets/goconvey/convey"
"net/url"
)
func
TestUrl
(
t
*
testing
.
T
)
{
...
...
@@ -43,4 +44,30 @@ func TestUrl(t *testing.T) {
So
(
result
,
ShouldEqual
,
"http://localhost:8080/api/"
)
})
Convey
(
"When joining two urls where lefthand side has a trailing slash and righthand side has preceding slash"
,
t
,
func
()
{
result
:=
JoinUrlFragments
(
"http://localhost:8080/"
,
"/api/"
)
So
(
result
,
ShouldEqual
,
"http://localhost:8080/api/"
)
})
}
func
TestNewUrlQueryReader
(
t
*
testing
.
T
)
{
u
,
_
:=
url
.
Parse
(
"http://www.abc.com/foo?bar=baz&bar2=baz2"
)
uqr
,
_
:=
NewUrlQueryReader
(
u
)
Convey
(
"when trying to retrieve the first query value"
,
t
,
func
()
{
result
:=
uqr
.
Get
(
"bar"
,
"foodef"
)
So
(
result
,
ShouldEqual
,
"baz"
)
})
Convey
(
"when trying to retrieve the second query value"
,
t
,
func
()
{
result
:=
uqr
.
Get
(
"bar2"
,
"foodef"
)
So
(
result
,
ShouldEqual
,
"baz2"
)
})
Convey
(
"when trying to retrieve from a non-existent key, the default value is returned"
,
t
,
func
()
{
result
:=
uqr
.
Get
(
"bar3"
,
"foodef"
)
So
(
result
,
ShouldEqual
,
"foodef"
)
})
}
pkg/util/validation_test.go
0 → 100644
View file @
e8dfbe94
package
util
import
(
"testing"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestIsEmail
(
t
*
testing
.
T
)
{
Convey
(
"When validating a string that is a valid email"
,
t
,
func
()
{
result
:=
IsEmail
(
"abc@def.com"
)
So
(
result
,
ShouldEqual
,
true
)
})
Convey
(
"When validating a string that is not a valid email"
,
t
,
func
()
{
result
:=
IsEmail
(
"abcdef.com"
)
So
(
result
,
ShouldEqual
,
false
)
})
}
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