mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-23 04:39:28 +02:00
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:
parent
4d2263e82e
commit
ce563ade3d
503 changed files with 5014 additions and 4665 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func tokens(s string) (a []any) {
|
||||
|
@ -20,15 +21,15 @@ func tokens(s string) (a []any) {
|
|||
|
||||
func TestEval(t *testing.T) {
|
||||
n, err := Expr(0, "/", 0.0)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, math.IsNaN(n.Value.(float64)))
|
||||
|
||||
_, err = Expr(nil)
|
||||
assert.ErrorContains(t, err, "unsupported token type")
|
||||
require.ErrorContains(t, err, "unsupported token type")
|
||||
_, err = Expr([]string{})
|
||||
assert.ErrorContains(t, err, "unsupported token type")
|
||||
require.ErrorContains(t, err, "unsupported token type")
|
||||
_, err = Expr(struct{}{})
|
||||
assert.ErrorContains(t, err, "unsupported token type")
|
||||
require.ErrorContains(t, err, "unsupported token type")
|
||||
|
||||
cases := []struct {
|
||||
expr string
|
||||
|
@ -69,9 +70,8 @@ func TestEval(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
n, err := Expr(tokens(c.expr)...)
|
||||
if assert.NoError(t, err, "expr: %s", c.expr) {
|
||||
assert.Equal(t, c.want, n.Value)
|
||||
}
|
||||
require.NoError(t, err, "expr: %s", c.expr)
|
||||
assert.Equal(t, c.want, n.Value)
|
||||
}
|
||||
|
||||
bads := []struct {
|
||||
|
@ -89,6 +89,6 @@ func TestEval(t *testing.T) {
|
|||
}
|
||||
for _, c := range bads {
|
||||
_, err = Expr(tokens(c.expr)...)
|
||||
assert.ErrorContains(t, err, c.errMsg, "expr: %s", c.expr)
|
||||
require.ErrorContains(t, err, c.errMsg, "expr: %s", c.expr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue