mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
39eba5065b
Add a default timezone that the administrator can set in the settings. This setting is be used as default for the users timezone preference. Can be used when creating Grafana instances without administrator intervention, in order to give user the correct default timezone. Fixes #25654
38 lines
897 B
Go
38 lines
897 B
Go
package setting
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gopkg.in/ini.v1"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestValueAsTimezone(t *testing.T) {
|
|
tests := map[string]struct {
|
|
output string
|
|
hasErr bool
|
|
}{
|
|
"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)
|
|
key, err := sec.NewKey("test", "")
|
|
assert.NoError(t, err)
|
|
|
|
for input, expected := range tests {
|
|
key.SetValue(input)
|
|
|
|
output, err := valueAsTimezone(sec, "test", "default")
|
|
|
|
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)
|
|
}
|
|
}
|