mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
This commit adds the following changes: - autostart enable|disable => autostart set|unset - autostart enable now accepts a more natual schedule format: <time> <days-of-week> <location> - autostart show now shows configured timezone - 🎉 automatic timezone detection across mac, windows, linux 🎉 Fixes #1647
41 lines
823 B
Go
41 lines
823 B
Go
package tz_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/coderd/util/tz"
|
|
)
|
|
|
|
//nolint:paralleltest // Environment variables
|
|
func Test_TimezoneIANA(t *testing.T) {
|
|
//nolint:paralleltest // t.Setenv
|
|
t.Run("Env", func(t *testing.T) {
|
|
t.Setenv("TZ", "Europe/Dublin")
|
|
|
|
zone, err := tz.TimezoneIANA()
|
|
assert.NoError(t, err)
|
|
if assert.NotNil(t, zone) {
|
|
assert.Equal(t, "Europe/Dublin", zone.String())
|
|
}
|
|
})
|
|
|
|
//nolint:paralleltest // UnsetEnv
|
|
t.Run("NoEnv", func(t *testing.T) {
|
|
oldEnv, found := os.LookupEnv("TZ")
|
|
if found {
|
|
require.NoError(t, os.Unsetenv("TZ"))
|
|
t.Cleanup(func() {
|
|
_ = os.Setenv("TZ", oldEnv)
|
|
})
|
|
}
|
|
|
|
zone, err := tz.TimezoneIANA()
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, zone)
|
|
})
|
|
}
|