mirror of
https://github.com/go-gitea/gitea
synced 2025-07-19 00:38:36 +00:00
Refactor older tests to use testify (#33140)
Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
package emoji
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -22,32 +21,18 @@ func TestLookup(t *testing.T) {
|
||||
c := FromAlias(":beer:")
|
||||
d := FromAlias("beer")
|
||||
|
||||
if !reflect.DeepEqual(a, b) {
|
||||
t.Errorf("a and b should equal")
|
||||
}
|
||||
if !reflect.DeepEqual(b, c) {
|
||||
t.Errorf("b and c should equal")
|
||||
}
|
||||
if !reflect.DeepEqual(c, d) {
|
||||
t.Errorf("c and d should equal")
|
||||
}
|
||||
if !reflect.DeepEqual(a, d) {
|
||||
t.Errorf("a and d should equal")
|
||||
}
|
||||
assert.Equal(t, a, b)
|
||||
assert.Equal(t, b, c)
|
||||
assert.Equal(t, c, d)
|
||||
assert.Equal(t, a, d)
|
||||
|
||||
m := FromCode("\U0001f44d")
|
||||
n := FromAlias(":thumbsup:")
|
||||
o := FromAlias("+1")
|
||||
|
||||
if !reflect.DeepEqual(m, n) {
|
||||
t.Errorf("m and n should equal")
|
||||
}
|
||||
if !reflect.DeepEqual(n, o) {
|
||||
t.Errorf("n and o should equal")
|
||||
}
|
||||
if !reflect.DeepEqual(m, o) {
|
||||
t.Errorf("m and o should equal")
|
||||
}
|
||||
assert.Equal(t, m, n)
|
||||
assert.Equal(t, m, o)
|
||||
assert.Equal(t, n, o)
|
||||
}
|
||||
|
||||
func TestReplacers(t *testing.T) {
|
||||
@@ -61,9 +46,7 @@ func TestReplacers(t *testing.T) {
|
||||
|
||||
for i, x := range tests {
|
||||
s := x.f(x.v)
|
||||
if s != x.exp {
|
||||
t.Errorf("test %d `%s` expected `%s`, got: `%s`", i, x.v, x.exp, s)
|
||||
}
|
||||
assert.Equalf(t, x.exp, s, "test %d `%s` expected `%s`, got: `%s`", i, x.v, x.exp, s)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user