grafana/pkg/setting/date_formats_test.go
Arve Knudsen ef2de2d357
setting: Fix tests on Mac (#28886)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-09 14:39:56 +01:00

37 lines
839 B
Go

package setting
import (
"testing"
"gopkg.in/ini.v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestValueAsTimezone(t *testing.T) {
tests := map[string]struct {
output string
hasErr bool
}{
"browser": {"browser", false},
"UTC": {"UTC", false},
"Amsterdam": {"browser", true},
"Europe/Amsterdam": {"Europe/Amsterdam", false},
}
sec, err := ini.Empty().NewSection("test")
require.NoError(t, err)
key, err := sec.NewKey("test", "")
require.NoError(t, err)
for input, expected := range tests {
key.SetValue(input)
output, err := valueAsTimezone(sec, "test")
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)
}
}