From 6bf73a59643267e858b7bbcefc229a02373896e1 Mon Sep 17 00:00:00 2001 From: Vincent Vielle Date: Mon, 7 Oct 2024 21:10:01 +0200 Subject: [PATCH] fix(coderd): move test location to ignore Australia time saving error (#15013) A test is currently failing because it relies on Sidney Tz. from the internet : ``` Daylight Saving Time begins at 2 am (AEST) on the first Sunday in October and ends at 3 am (Australian Eastern Daylight Time) on the first Sunday in April. ``` Due to that - there's one hour missing in the tests - and the test `6 days are acceptable` is failing. Changing to another timezone to fix the situation, it would require a longer-term solution or making sure it cannot happen anymore. --- coderd/insights_internal_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coderd/insights_internal_test.go b/coderd/insights_internal_test.go index 88086581f1..bfd93b6f68 100644 --- a/coderd/insights_internal_test.go +++ b/coderd/insights_internal_test.go @@ -179,17 +179,17 @@ func Test_parseInsightsInterval_week(t *testing.T) { t.Parallel() layout := insightsTimeLayout - sydneyLoc, err := time.LoadLocation("Australia/Sydney") // Random location + losAngelesLoc, err := time.LoadLocation("America/Los_Angeles") // Random location require.NoError(t, err) - now := time.Now().In(sydneyLoc) + now := time.Now().In(losAngelesLoc) t.Logf("now: %s", now) y, m, d := now.Date() - today := time.Date(y, m, d, 0, 0, 0, 0, sydneyLoc) + today := time.Date(y, m, d, 0, 0, 0, 0, losAngelesLoc) t.Logf("today: %s", today) - thisHour := time.Date(y, m, d, now.Hour(), 0, 0, 0, sydneyLoc) + thisHour := time.Date(y, m, d, now.Hour(), 0, 0, 0, losAngelesLoc) t.Logf("thisHour: %s", thisHour) twoHoursAgo := thisHour.Add(-2 * time.Hour) t.Logf("twoHoursAgo: %s", twoHoursAgo)