mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-06-03 12:00:02 +02:00
enable linter testifylint on v7 (#4572)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4572 Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
parent
c47bdf436b
commit
072dd9f8bc
494 changed files with 4897 additions and 4554 deletions
|
@ -4,11 +4,11 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEncodeSha1(t *testing.T) {
|
||||
|
@ -34,15 +34,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) {
|
||||
|
@ -81,7 +81,7 @@ func testCreateTimeLimitCode(t *testing.T, data string, m int) string {
|
|||
assert.Equal(t, result0, result1)
|
||||
assert.NotEqual(t, result0, result2)
|
||||
|
||||
assert.True(t, len(result0) != 0)
|
||||
assert.NotEmpty(t, result0)
|
||||
return result0
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,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)
|
||||
|
@ -144,8 +144,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) {
|
||||
|
@ -159,9 +159,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())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue