Add testifylint to lint checks (#4535)

go-require lint is ignored for now

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4535
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
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:10 +00:00 committed by Earl Warren
parent 94933470cd
commit 4de909747b
504 changed files with 5028 additions and 4680 deletions

View file

@ -10,6 +10,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDict(t *testing.T) {
@ -27,9 +28,8 @@ func TestDict(t *testing.T) {
for _, c := range cases {
got, err := dict(c.args...)
if assert.NoError(t, err) {
assert.EqualValues(t, c.want, got)
}
require.NoError(t, err)
assert.EqualValues(t, c.want, got)
}
bads := []struct {
@ -41,7 +41,7 @@ func TestDict(t *testing.T) {
}
for _, c := range bads {
_, err := dict(c.args...)
assert.Error(t, err)
require.Error(t, err)
}
}
@ -51,7 +51,7 @@ func TestUtils(t *testing.T) {
tmpl.Funcs(template.FuncMap{"SliceUtils": NewSliceUtils, "StringUtils": NewStringUtils})
template.Must(tmpl.Parse(code))
w := &strings.Builder{}
assert.NoError(t, tmpl.Execute(w, data))
require.NoError(t, tmpl.Execute(w, data))
return w.String()
}
@ -75,5 +75,5 @@ func TestUtils(t *testing.T) {
template.Must(tmpl.Parse("{{SliceUtils.Contains .Slice .Value}}"))
// error is like this: `template: test:1:12: executing "test" at <SliceUtils.Contains>: error calling Contains: ...`
err := tmpl.Execute(io.Discard, map[string]any{"Slice": struct{}{}})
assert.ErrorContains(t, err, "invalid type, expected slice or array")
require.ErrorContains(t, err, "invalid type, expected slice or array")
}