From 983d23617e2e67a64b05e812342171a227446198 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Wed, 8 Jan 2025 15:15:54 +0100 Subject: [PATCH] Fixed tests --- internal/models/ApiKey_test.go | 6 ++++++ internal/models/User_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/internal/models/ApiKey_test.go b/internal/models/ApiKey_test.go index 5ad8529..accdd1d 100644 --- a/internal/models/ApiKey_test.go +++ b/internal/models/ApiKey_test.go @@ -2,6 +2,7 @@ package models import ( "github.com/forceu/gokapi/internal/test" + "os" "testing" ) @@ -9,7 +10,12 @@ func TestApiKey_GetReadableDate(t *testing.T) { key := &ApiKey{} test.IsEqualString(t, key.GetReadableDate(), "Never") key.LastUsed = 1736276120 + lastTz := os.Getenv("TZ") + err := os.Setenv("TZ", "Europe/Berlin") + test.IsNil(t, err) test.IsEqualString(t, key.GetReadableDate(), "2025-01-07 19:55:20") + err = os.Setenv("TZ", lastTz) + test.IsNil(t, err) } func TestApiKey_GetRedactedId(t *testing.T) { diff --git a/internal/models/User_test.go b/internal/models/User_test.go index 2cb131d..27695a8 100644 --- a/internal/models/User_test.go +++ b/internal/models/User_test.go @@ -2,6 +2,7 @@ package models import ( "github.com/forceu/gokapi/internal/test" + "os" "testing" "time" ) @@ -22,6 +23,12 @@ func TestUser_GetReadableDate(t *testing.T) { date = u.GetReadableDate() test.IsEqualString(t, date, "Online") u.LastOnline = 1736276120 + + lastTz := os.Getenv("TZ") + err := os.Setenv("TZ", "Europe/Berlin") + test.IsNil(t, err) date = u.GetReadableDate() test.IsEqualString(t, date, "2025-01-07 19:55") + err = os.Setenv("TZ", lastTz) + test.IsNil(t, err) }