MCPcopy Index your code
hub / github.com/coder/coder / Test_TimezoneIANA

Function Test_TimezoneIANA

coderd/util/tz/tz_test.go:15–47  ·  view source on GitHub ↗

nolint:paralleltest // Environment variables

(t *testing.T)

Source from the content-addressed store, hash-verified

13
14//nolint:paralleltest // Environment variables
15func Test_TimezoneIANA(t *testing.T) {
16 //nolint:paralleltest // t.Setenv
17 t.Run("Env", func(t *testing.T) {
18 t.Setenv("TZ", "Europe/Dublin")
19
20 zone, err := tz.TimezoneIANA()
21 assert.NoError(t, err)
22 if assert.NotNil(t, zone) {
23 assert.Equal(t, "Europe/Dublin", zone.String())
24 }
25 })
26
27 //nolint:paralleltest // UnsetEnv
28 t.Run("NoEnv", func(t *testing.T) {
29 _, err := os.Stat("/etc/localtime")
30 if runtime.GOOS == "linux" && err != nil {
31 // Not all Linux operating systems are guaranteed to have localtime!
32 t.Skip("localtime doesn't exist!")
33 }
34 if runtime.GOOS == "windows" {
35 // This test can be flaky on some Windows runners :(
36 t.Skip("This test is flaky under Windows.")
37 }
38 _, found := os.LookupEnv("TZ")
39 if found {
40 require.NoError(t, os.Unsetenv("TZ"))
41 }
42
43 zone, err := tz.TimezoneIANA()
44 assert.NoError(t, err)
45 assert.NotNil(t, zone)
46 })
47}

Callers

nothing calls this directly

Calls 6

TimezoneIANAFunction · 0.92
SetenvMethod · 0.80
SkipMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected