From 0d9d93d0c02a18b135b7f1e215b3c4d60b939aed Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 7 Oct 2024 15:59:01 +0200 Subject: [PATCH 1/2] fix: change test location to ignore Australia time saving error --- coderd/insights_internal_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/insights_internal_test.go b/coderd/insights_internal_test.go index 88086581f1b51..13913bacbe618 100644 --- a/coderd/insights_internal_test.go +++ b/coderd/insights_internal_test.go @@ -179,7 +179,7 @@ func Test_parseInsightsInterval_week(t *testing.T) { t.Parallel() layout := insightsTimeLayout - sydneyLoc, err := time.LoadLocation("Australia/Sydney") // Random location + sydneyLoc, err := time.LoadLocation("America/Los_Angeles") // Random location require.NoError(t, err) now := time.Now().In(sydneyLoc) From 313877877560fbe3be07c7758100d1c22eefd2f9 Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 7 Oct 2024 16:08:52 +0200 Subject: [PATCH 2/2] fix: improve var naming with new location --- 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 13913bacbe618..bfd93b6f687b8 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("America/Los_Angeles") // 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)