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
1698c74e
Unverified
Commit
1698c74e
authored
Aug 12, 2020
by
Arve Knudsen
Committed by
GitHub
Aug 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Fix tests for Go 1.15 (#26957)
* Chore: Fix tests for Go 1.15
parent
a8f57b2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
12 deletions
+18
-12
pkg/api/dashboard_test.go
+1
-1
pkg/components/gtime/gtime_test.go
+6
-4
pkg/services/sqlstore/alert_notification_test.go
+5
-2
pkg/services/sqlstore/sqlbuilder_test.go
+6
-5
No files found.
pkg/api/dashboard_test.go
View file @
1698c74e
...
...
@@ -828,7 +828,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
bus
.
AddHandler
(
"test"
,
func
(
query
*
models
.
GetDashboardVersionQuery
)
error
{
query
.
Result
=
&
models
.
DashboardVersion
{
Data
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"title"
:
"Dash"
+
string
(
query
.
DashboardId
),
"title"
:
fmt
.
Sprintf
(
"Dash%d"
,
query
.
DashboardId
),
}),
}
return
nil
...
...
pkg/components/gtime/gtime_test.go
View file @
1698c74e
...
...
@@ -2,6 +2,7 @@ package gtime
import
(
"fmt"
"regexp"
"testing"
"time"
...
...
@@ -14,7 +15,7 @@ func TestParseInterval(t *testing.T) {
tcs
:=
[]
struct
{
interval
string
duration
time
.
Duration
err
string
err
*
regexp
.
Regexp
}{
{
interval
:
"1d"
,
duration
:
now
.
Sub
(
now
.
AddDate
(
0
,
0
,
-
1
))},
{
interval
:
"1w"
,
duration
:
now
.
Sub
(
now
.
AddDate
(
0
,
0
,
-
7
))},
...
...
@@ -22,17 +23,18 @@ func TestParseInterval(t *testing.T) {
{
interval
:
"1M"
,
duration
:
now
.
Sub
(
now
.
AddDate
(
0
,
-
1
,
0
))},
{
interval
:
"1y"
,
duration
:
now
.
Sub
(
now
.
AddDate
(
-
1
,
0
,
0
))},
{
interval
:
"5y"
,
duration
:
now
.
Sub
(
now
.
AddDate
(
-
5
,
0
,
0
))},
{
interval
:
"invalid-duration"
,
err
:
"time: invalid duration invalid-duration"
},
{
interval
:
"invalid-duration"
,
err
:
regexp
.
MustCompile
(
`^time: invalid duration "?invalid-duration"?$`
)
},
}
for
i
,
tc
:=
range
tcs
{
t
.
Run
(
fmt
.
Sprintf
(
"testcase %d"
,
i
),
func
(
t
*
testing
.
T
)
{
res
,
err
:=
ParseInterval
(
tc
.
interval
)
if
tc
.
err
==
""
{
if
tc
.
err
==
nil
{
require
.
NoError
(
t
,
err
,
"interval %q"
,
tc
.
interval
)
require
.
Equal
(
t
,
tc
.
duration
,
res
,
"interval %q"
,
tc
.
interval
)
}
else
{
require
.
EqualError
(
t
,
err
,
tc
.
err
,
"interval %q"
,
tc
.
interval
)
require
.
Error
(
t
,
err
,
"interval %q"
,
tc
.
interval
)
require
.
Regexp
(
t
,
tc
.
err
,
err
.
Error
())
}
})
}
...
...
pkg/services/sqlstore/alert_notification_test.go
View file @
1698c74e
...
...
@@ -2,6 +2,7 @@ package sqlstore
import
(
"context"
"regexp"
"testing"
"time"
...
...
@@ -168,7 +169,8 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
cmd
.
Frequency
=
"invalid duration"
err
:=
CreateAlertNotificationCommand
(
cmd
)
So
(
err
.
Error
(),
ShouldEqual
,
"time: invalid duration invalid duration"
)
So
(
regexp
.
MustCompile
(
`^time: invalid duration "?invalid duration"?$`
)
.
MatchString
(
err
.
Error
()),
ShouldBeTrue
)
})
})
...
...
@@ -199,7 +201,8 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
err
:=
UpdateAlertNotification
(
updateCmd
)
So
(
err
,
ShouldNotBeNil
)
So
(
err
.
Error
(),
ShouldEqual
,
"time: invalid duration invalid duration"
)
So
(
regexp
.
MustCompile
(
`^time: invalid duration "?invalid duration"?$`
)
.
MatchString
(
err
.
Error
()),
ShouldBeTrue
)
})
})
...
...
pkg/services/sqlstore/sqlbuilder_test.go
View file @
1698c74e
...
...
@@ -3,6 +3,7 @@ package sqlstore
import
(
"context"
"math/rand"
"strconv"
"testing"
"time"
...
...
@@ -191,14 +192,14 @@ func test(t *testing.T, dashboardProps DashboardProps, dashboardPermission *Dash
}
func
createDummyUser
()
(
*
models
.
User
,
error
)
{
uid
:=
rand
.
Intn
(
9999999
)
uid
:=
strconv
.
Itoa
(
rand
.
Intn
(
9999999
)
)
createUserCmd
:=
&
models
.
CreateUserCommand
{
Email
:
string
(
uid
)
+
"@example.com"
,
Login
:
string
(
uid
)
,
Name
:
string
(
uid
)
,
Email
:
uid
+
"@example.com"
,
Login
:
uid
,
Name
:
uid
,
Company
:
""
,
OrgName
:
""
,
Password
:
string
(
uid
)
,
Password
:
uid
,
EmailVerified
:
true
,
IsAdmin
:
false
,
SkipOrgSetup
:
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