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
ef2de2d3
Unverified
Commit
ef2de2d3
authored
Nov 09, 2020
by
Arve Knudsen
Committed by
GitHub
Nov 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setting: Fix tests on Mac (#28886)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent
2ddda8f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
pkg/setting/date_formats.go
+7
-8
pkg/setting/date_formats_test.go
+6
-7
No files found.
pkg/setting/date_formats.go
View file @
ef2de2d3
...
...
@@ -22,18 +22,17 @@ type DateFormatIntervals struct {
Year
string
`json:"year"`
}
const
L
ocalBrowserTimezone
=
"browser"
const
l
ocalBrowserTimezone
=
"browser"
func
valueAsTimezone
(
section
*
ini
.
Section
,
keyName
string
,
defaultValue
string
)
(
string
,
error
)
{
timezone
:=
section
.
Key
(
keyName
)
.
MustString
(
defaultValue
)
if
timezone
==
LocalBrowserTimezone
{
return
LocalBrowserTimezone
,
nil
func
valueAsTimezone
(
section
*
ini
.
Section
,
keyName
string
)
(
string
,
error
)
{
timezone
:=
section
.
Key
(
keyName
)
.
MustString
(
localBrowserTimezone
)
if
timezone
==
localBrowserTimezone
{
return
localBrowserTimezone
,
nil
}
location
,
err
:=
time
.
LoadLocation
(
timezone
)
if
err
!=
nil
{
return
L
ocalBrowserTimezone
,
err
return
l
ocalBrowserTimezone
,
err
}
return
location
.
String
(),
nil
...
...
@@ -50,7 +49,7 @@ func (cfg *Cfg) readDateFormats() {
cfg
.
DateFormats
.
Interval
.
Year
=
"YYYY"
cfg
.
DateFormats
.
UseBrowserLocale
=
dateFormats
.
Key
(
"date_format_use_browser_locale"
)
.
MustBool
(
false
)
timezone
,
err
:=
valueAsTimezone
(
dateFormats
,
"default_timezone"
,
LocalBrowserTimezone
)
timezone
,
err
:=
valueAsTimezone
(
dateFormats
,
"default_timezone"
)
if
err
!=
nil
{
cfg
.
Logger
.
Warn
(
"Unknown timezone as default_timezone"
,
"err"
,
err
)
}
...
...
pkg/setting/date_formats_test.go
View file @
ef2de2d3
...
...
@@ -6,6 +6,7 @@ import (
"gopkg.in/ini.v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func
TestValueAsTimezone
(
t
*
testing
.
T
)
{
...
...
@@ -15,23 +16,21 @@ func TestValueAsTimezone(t *testing.T) {
}{
"browser"
:
{
"browser"
,
false
},
"UTC"
:
{
"UTC"
,
false
},
"utc"
:
{
"browser"
,
true
},
"Amsterdam"
:
{
"browser"
,
true
},
"europe/amsterdam"
:
{
"browser"
,
true
},
"Europe/Amsterdam"
:
{
"Europe/Amsterdam"
,
false
},
}
sec
,
err
:=
ini
.
Empty
()
.
NewSection
(
"test"
)
assert
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
key
,
err
:=
sec
.
NewKey
(
"test"
,
""
)
assert
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
for
input
,
expected
:=
range
tests
{
key
.
SetValue
(
input
)
output
,
err
:=
valueAsTimezone
(
sec
,
"test"
,
"default"
)
output
,
err
:=
valueAsTimezone
(
sec
,
"test"
)
assert
.
Equal
(
t
,
expected
.
hasErr
,
err
!=
nil
,
"Invalid has err for input
: %s err: %v
"
,
input
,
err
)
assert
.
Equal
(
t
,
expected
.
output
,
output
,
"Invalid output for input
: %s
"
,
input
)
assert
.
Equal
(
t
,
expected
.
hasErr
,
err
!=
nil
,
"Invalid has err for input
%q: %s
"
,
input
,
err
)
assert
.
Equal
(
t
,
expected
.
output
,
output
,
"Invalid output for input
%q
"
,
input
)
}
}
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