Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Jan 8, 2025
1 parent 15509b7 commit 983d236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/models/ApiKey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ package models

import (
"github.com/forceu/gokapi/internal/test"
"os"
"testing"
)

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) {
Expand Down
7 changes: 7 additions & 0 deletions internal/models/User_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import (
"github.com/forceu/gokapi/internal/test"
"os"
"testing"
"time"
)
Expand All @@ -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)
}

0 comments on commit 983d236

Please sign in to comment.