enable linter testifylint on v8 (#4573)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4573
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
TheFox0x7 2024-07-30 19:41:27 +00:00 committed by Earl Warren
parent 4d2263e82e
commit ce563ade3d
503 changed files with 5014 additions and 4665 deletions

View file

@ -6,7 +6,6 @@ package base
import (
"crypto/sha1"
"fmt"
"os"
"testing"
"time"
@ -14,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestEncodeSha256(t *testing.T) {
@ -32,15 +32,15 @@ func TestBasicAuthDecode(t *testing.T) {
assert.Equal(t, "illegal base64 data at input byte 0", err.Error())
user, pass, err := BasicAuthDecode("Zm9vOmJhcg==")
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "foo", user)
assert.Equal(t, "bar", pass)
_, _, err = BasicAuthDecode("aW52YWxpZA==")
assert.Error(t, err)
require.Error(t, err)
_, _, err = BasicAuthDecode("invalid")
assert.Error(t, err)
require.Error(t, err)
}
func TestVerifyTimeLimitCode(t *testing.T) {
@ -144,7 +144,7 @@ func TestTruncateString(t *testing.T) {
func TestStringsToInt64s(t *testing.T) {
testSuccess := func(input []string, expected []int64) {
result, err := StringsToInt64s(input)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, expected, result)
}
testSuccess(nil, nil)
@ -153,8 +153,8 @@ func TestStringsToInt64s(t *testing.T) {
testSuccess([]string{"1", "4", "16", "64", "256"}, []int64{1, 4, 16, 64, 256})
ints, err := StringsToInt64s([]string{"-1", "a"})
assert.Len(t, ints, 0)
assert.Error(t, err)
assert.Empty(t, ints)
require.Error(t, err)
}
func TestInt64sToStrings(t *testing.T) {
@ -168,9 +168,9 @@ func TestInt64sToStrings(t *testing.T) {
// TODO: Test EntryIcon
func TestSetupGiteaRoot(t *testing.T) {
_ = os.Setenv("GITEA_ROOT", "test")
t.Setenv("GITEA_ROOT", "test")
assert.Equal(t, "test", SetupGiteaRoot())
_ = os.Setenv("GITEA_ROOT", "")
t.Setenv("GITEA_ROOT", "")
assert.NotEqual(t, "test", SetupGiteaRoot())
}