aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/auth_token_test.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-12-28 18:09:57 +0800
committerGitHub <noreply@github.com>2023-12-28 10:09:57 +0000
commite743570f65b533552337d9606ac1d906ec054127 (patch)
tree55042505c0618b567e7f30e7334ec6d66db86230 /services/auth/auth_token_test.go
parentf3999888c0b765380003f814f9c3d5cf80128167 (diff)
downloadgitea-e743570f65b533552337d9606ac1d906ec054127.tar.gz
gitea-e743570f65b533552337d9606ac1d906ec054127.zip
Refactor timeutil package (#28623)
1. make names more readable 2. remove unused FormatLong/FormatShort 3. use `FormatDate` instead of `Format "2006-01-02"`
Diffstat (limited to 'services/auth/auth_token_test.go')
-rw-r--r--services/auth/auth_token_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/services/auth/auth_token_test.go b/services/auth/auth_token_test.go
index 654275df17..23c8d17e59 100644
--- a/services/auth/auth_token_test.go
+++ b/services/auth/auth_token_test.go
@@ -37,14 +37,14 @@ func TestCheckAuthToken(t *testing.T) {
})
t.Run("Expired", func(t *testing.T) {
- timeutil.Set(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC))
+ timeutil.MockSet(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC))
at, token, err := CreateAuthTokenForUserID(db.DefaultContext, 2)
assert.NoError(t, err)
assert.NotNil(t, at)
assert.NotEmpty(t, token)
- timeutil.Unset()
+ timeutil.MockUnset()
at2, err := CheckAuthToken(db.DefaultContext, at.ID+":"+token)
assert.ErrorIs(t, err, ErrAuthTokenExpired)
@@ -83,15 +83,15 @@ func TestCheckAuthToken(t *testing.T) {
func TestRegenerateAuthToken(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- timeutil.Set(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC))
- defer timeutil.Unset()
+ timeutil.MockSet(time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC))
+ defer timeutil.MockUnset()
at, token, err := CreateAuthTokenForUserID(db.DefaultContext, 2)
assert.NoError(t, err)
assert.NotNil(t, at)
assert.NotEmpty(t, token)
- timeutil.Set(time.Date(2023, 1, 1, 0, 0, 1, 0, time.UTC))
+ timeutil.MockSet(time.Date(2023, 1, 1, 0, 0, 1, 0, time.UTC))
at2, token2, err := RegenerateAuthToken(db.DefaultContext, at)
assert.NoError(t, err)