Skip to content

Commit 5c56019

Browse files
committed
Merge branch 'main' into lunny/refactor
2 parents 22d2fff + 2a02734 commit 5c56019

File tree

75 files changed

+1489
-1599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1489
-1599
lines changed

assets/go-licenses.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/ProtonMail/go-crypto v1.1.4
2828
github.com/PuerkitoBio/goquery v1.10.0
2929
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.3
30-
github.com/alecthomas/chroma/v2 v2.14.0
30+
github.com/alecthomas/chroma/v2 v2.15.0
3131
github.com/aws/aws-sdk-go-v2/credentials v1.17.42
3232
github.com/aws/aws-sdk-go-v2/service/codecommit v1.27.3
3333
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
@@ -112,22 +112,22 @@ require (
112112
github.com/ulikunitz/xz v0.5.12
113113
github.com/urfave/cli/v2 v2.27.5
114114
github.com/wneessen/go-mail v0.5.2
115-
github.com/xanzy/go-gitlab v0.112.0
116115
github.com/xeipuuv/gojsonschema v1.2.0
117116
github.com/yohcop/openid-go v1.0.1
118117
github.com/yuin/goldmark v1.7.8
119118
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
120119
github.com/yuin/goldmark-meta v1.1.0
120+
gitlab.com/gitlab-org/api/client-go v0.119.0
121121
golang.org/x/crypto v0.32.0
122122
golang.org/x/image v0.21.0
123123
golang.org/x/net v0.34.0
124-
golang.org/x/oauth2 v0.23.0
124+
golang.org/x/oauth2 v0.24.0
125125
golang.org/x/sync v0.10.0
126126
golang.org/x/sys v0.29.0
127127
golang.org/x/text v0.21.0
128128
golang.org/x/tools v0.29.0
129129
google.golang.org/grpc v1.67.1
130-
google.golang.org/protobuf v1.35.1
130+
google.golang.org/protobuf v1.36.0
131131
gopkg.in/ini.v1 v1.67.0
132132
gopkg.in/yaml.v3 v3.0.1
133133
mvdan.cc/xurls/v2 v2.5.0
@@ -306,7 +306,7 @@ require (
306306
go.uber.org/zap v1.27.0 // indirect
307307
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
308308
golang.org/x/mod v0.22.0 // indirect
309-
golang.org/x/time v0.7.0 // indirect
309+
golang.org/x/time v0.8.0 // indirect
310310
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
311311
gopkg.in/warnings.v0 v0.1.2 // indirect
312312
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv
8181
github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
8282
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.3 h1:BP0HiyNT3AQEYi+if3wkRcIdQFHtsw6xX3Kx0glckgA=
8383
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.3/go.mod h1:hMNtySovKkn2gdDuLqnqveP+mfhUSaBdoBcr2I7Zt0E=
84-
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
85-
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
84+
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
85+
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
8686
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
87-
github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
88-
github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
87+
github.com/alecthomas/chroma/v2 v2.15.0 h1:LxXTQHFoYrstG2nnV9y2X5O94sOBzf0CIUpSTbpxvMc=
88+
github.com/alecthomas/chroma/v2 v2.15.0/go.mod h1:gUhVLrPDXPtp/f+L1jo9xepo9gL4eLwRuGAunSZMkio=
8989
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
9090
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
9191
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
@@ -766,8 +766,6 @@ github.com/wneessen/go-mail v0.5.2 h1:MZKwgHJoRboLJ+EHMLuHpZc95wo+u1xViL/4XSswDT
766766
github.com/wneessen/go-mail v0.5.2/go.mod h1:kRroJvEq2hOSEPFRiKjN7Csrz0G1w+RpiGR3b6yo+Ck=
767767
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
768768
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
769-
github.com/xanzy/go-gitlab v0.112.0 h1:6Z0cqEooCvBMfBIHw+CgO4AKGRV8na/9781xOb0+DKw=
770-
github.com/xanzy/go-gitlab v0.112.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
771769
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
772770
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
773771
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@@ -802,6 +800,8 @@ github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
802800
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
803801
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
804802
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
803+
gitlab.com/gitlab-org/api/client-go v0.119.0 h1:YBZyx9XUTtEDBBYtY36cZWz6JmT7om/8HPSk37IS95g=
804+
gitlab.com/gitlab-org/api/client-go v0.119.0/go.mod h1:ygHmS3AU3TpvK+AC6DYO1QuAxLlv6yxYK+/Votr/WFQ=
805805
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
806806
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
807807
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
@@ -867,8 +867,8 @@ golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
867867
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
868868
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
869869
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
870-
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
871-
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
870+
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
871+
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
872872
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
873873
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
874874
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -942,8 +942,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
942942
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
943943
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
944944
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
945-
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
946-
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
945+
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
946+
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
947947
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
948948
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
949949
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
@@ -970,8 +970,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
970970
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
971971
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
972972
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
973-
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
974-
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
973+
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
974+
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
975975
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
976976
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
977977
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

models/asymkey/gpg_key_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/keybase/go-crypto/openpgp/packet"
1717
"github.com/stretchr/testify/assert"
18+
"github.com/stretchr/testify/require"
1819
)
1920

2021
func TestCheckArmoredGPGKeyString(t *testing.T) {
@@ -107,9 +108,8 @@ MkM/fdpyc2hY7Dl/+qFmN5MG5yGmMpQcX+RNNR222ibNC1D3wg==
107108
=i9b7
108109
-----END PGP PUBLIC KEY BLOCK-----`
109110
keys, err := checkArmoredGPGKeyString(testGPGArmor)
110-
if !assert.NotEmpty(t, keys) {
111-
return
112-
}
111+
require.NotEmpty(t, keys)
112+
113113
ekey := keys[0]
114114
assert.NoError(t, err, "Could not parse a valid GPG armored key", ekey)
115115

models/db/engine_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
_ "code.gitea.io/gitea/cmd" // for TestPrimaryKeys
1616

1717
"github.com/stretchr/testify/assert"
18+
"github.com/stretchr/testify/require"
1819
)
1920

2021
func TestDumpDatabase(t *testing.T) {
@@ -62,9 +63,7 @@ func TestPrimaryKeys(t *testing.T) {
6263
// Import "code.gitea.io/gitea/cmd" to make sure each db.RegisterModel in init functions has been called.
6364

6465
beans, err := db.NamesToBean()
65-
if err != nil {
66-
t.Fatal(err)
67-
}
66+
require.NoError(t, err)
6867

6968
whitelist := map[string]string{
7069
"the_table_name_to_skip_checking": "Write a note here to explain why",
@@ -79,8 +78,6 @@ func TestPrimaryKeys(t *testing.T) {
7978
t.Logf("ignore %q because %q", table.Name, why)
8079
continue
8180
}
82-
if len(table.PrimaryKeys) == 0 {
83-
t.Errorf("table %q has no primary key", table.Name)
84-
}
81+
assert.NotEmpty(t, table.PrimaryKeys, "table %q has no primary key", table.Name)
8582
}
8683
}

models/organization/org_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/structs"
1717

1818
"github.com/stretchr/testify/assert"
19+
"github.com/stretchr/testify/require"
1920
)
2021

2122
func TestUser_IsOwnedBy(t *testing.T) {
@@ -180,9 +181,8 @@ func TestRestrictedUserOrgMembers(t *testing.T) {
180181
ID: 29,
181182
IsRestricted: true,
182183
})
183-
if !assert.True(t, restrictedUser.IsRestricted) {
184-
return // ensure fixtures return restricted user
185-
}
184+
// ensure fixtures return restricted user
185+
require.True(t, restrictedUser.IsRestricted)
186186

187187
testCases := []struct {
188188
name string

models/user/openid_test.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
user_model "code.gitea.io/gitea/models/user"
1212

1313
"github.com/stretchr/testify/assert"
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
func TestGetUserOpenIDs(t *testing.T) {
@@ -34,30 +35,23 @@ func TestGetUserOpenIDs(t *testing.T) {
3435
func TestToggleUserOpenIDVisibility(t *testing.T) {
3536
assert.NoError(t, unittest.PrepareTestDatabase())
3637
oids, err := user_model.GetUserOpenIDs(db.DefaultContext, int64(2))
37-
if !assert.NoError(t, err) || !assert.Len(t, oids, 1) {
38-
return
39-
}
38+
require.NoError(t, err)
39+
require.Len(t, oids, 1)
4040
assert.True(t, oids[0].Show)
4141

4242
err = user_model.ToggleUserOpenIDVisibility(db.DefaultContext, oids[0].ID)
43-
if !assert.NoError(t, err) {
44-
return
45-
}
43+
require.NoError(t, err)
4644

4745
oids, err = user_model.GetUserOpenIDs(db.DefaultContext, int64(2))
48-
if !assert.NoError(t, err) || !assert.Len(t, oids, 1) {
49-
return
50-
}
46+
require.NoError(t, err)
47+
require.Len(t, oids, 1)
48+
5149
assert.False(t, oids[0].Show)
5250
err = user_model.ToggleUserOpenIDVisibility(db.DefaultContext, oids[0].ID)
53-
if !assert.NoError(t, err) {
54-
return
55-
}
51+
require.NoError(t, err)
5652

5753
oids, err = user_model.GetUserOpenIDs(db.DefaultContext, int64(2))
58-
if !assert.NoError(t, err) {
59-
return
60-
}
54+
require.NoError(t, err)
6155
if assert.Len(t, oids, 1) {
6256
assert.True(t, oids[0].Show)
6357
}

modules/analyze/vendor_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
package analyze
55

6-
import "testing"
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
711

812
func TestIsVendor(t *testing.T) {
913
tests := []struct {
@@ -33,9 +37,8 @@ func TestIsVendor(t *testing.T) {
3337
}
3438
for _, tt := range tests {
3539
t.Run(tt.path, func(t *testing.T) {
36-
if got := IsVendor(tt.path); got != tt.want {
37-
t.Errorf("IsVendor() = %v, want %v", got, tt.want)
38-
}
40+
got := IsVendor(tt.path)
41+
assert.Equal(t, tt.want, got)
3942
})
4043
}
4144
}

modules/auth/openid/discovery_cache_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ package openid
66
import (
77
"testing"
88
"time"
9+
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
912
)
1013

1114
type testDiscoveredInfo struct{}
@@ -29,21 +32,17 @@ func TestTimedDiscoveryCache(t *testing.T) {
2932
dc.Put("foo", &testDiscoveredInfo{}) // openid.opEndpoint: "a", openid.opLocalID: "b", openid.claimedID: "c"})
3033

3134
// Make sure we can retrieve them
32-
if di := dc.Get("foo"); di == nil {
33-
t.Errorf("Expected a result, got nil")
34-
} else if di.OpEndpoint() != "opEndpoint" || di.OpLocalID() != "opLocalID" || di.ClaimedID() != "claimedID" {
35-
t.Errorf("Expected opEndpoint opLocalID claimedID, got %v %v %v", di.OpEndpoint(), di.OpLocalID(), di.ClaimedID())
36-
}
35+
di := dc.Get("foo")
36+
require.NotNil(t, di)
37+
assert.Equal(t, "opEndpoint", di.OpEndpoint())
38+
assert.Equal(t, "opLocalID", di.OpLocalID())
39+
assert.Equal(t, "claimedID", di.ClaimedID())
3740

3841
// Attempt to get a non-existent value
39-
if di := dc.Get("bar"); di != nil {
40-
t.Errorf("Expected nil, got %v", di)
41-
}
42+
assert.Nil(t, dc.Get("bar"))
4243

4344
// Sleep one second and try retrieve again
4445
time.Sleep(1 * time.Second)
4546

46-
if di := dc.Get("foo"); di != nil {
47-
t.Errorf("Expected a nil, got a result")
48-
}
47+
assert.Nil(t, dc.Get("foo"))
4948
}

modules/emoji/emoji_test.go

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package emoji
66

77
import (
8-
"reflect"
98
"testing"
109

1110
"github.com/stretchr/testify/assert"
@@ -22,32 +21,18 @@ func TestLookup(t *testing.T) {
2221
c := FromAlias(":beer:")
2322
d := FromAlias("beer")
2423

25-
if !reflect.DeepEqual(a, b) {
26-
t.Errorf("a and b should equal")
27-
}
28-
if !reflect.DeepEqual(b, c) {
29-
t.Errorf("b and c should equal")
30-
}
31-
if !reflect.DeepEqual(c, d) {
32-
t.Errorf("c and d should equal")
33-
}
34-
if !reflect.DeepEqual(a, d) {
35-
t.Errorf("a and d should equal")
36-
}
24+
assert.Equal(t, a, b)
25+
assert.Equal(t, b, c)
26+
assert.Equal(t, c, d)
27+
assert.Equal(t, a, d)
3728

3829
m := FromCode("\U0001f44d")
3930
n := FromAlias(":thumbsup:")
4031
o := FromAlias("+1")
4132

42-
if !reflect.DeepEqual(m, n) {
43-
t.Errorf("m and n should equal")
44-
}
45-
if !reflect.DeepEqual(n, o) {
46-
t.Errorf("n and o should equal")
47-
}
48-
if !reflect.DeepEqual(m, o) {
49-
t.Errorf("m and o should equal")
50-
}
33+
assert.Equal(t, m, n)
34+
assert.Equal(t, m, o)
35+
assert.Equal(t, n, o)
5136
}
5237

5338
func TestReplacers(t *testing.T) {
@@ -61,9 +46,7 @@ func TestReplacers(t *testing.T) {
6146

6247
for i, x := range tests {
6348
s := x.f(x.v)
64-
if s != x.exp {
65-
t.Errorf("test %d `%s` expected `%s`, got: `%s`", i, x.v, x.exp, s)
66-
}
49+
assert.Equalf(t, x.exp, s, "test %d `%s` expected `%s`, got: `%s`", i, x.v, x.exp, s)
6750
}
6851
}
6952

0 commit comments

Comments
 (0)