Skip to content

Commit 7e2b230

Browse files
committed
tests: replaced stretchr/testify by go-openapi/testify
Signed-off-by: Frederic BIDON <[email protected]>
1 parent bf4e21a commit 7e2b230

File tree

12 files changed

+44
-65
lines changed

12 files changed

+44
-65
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors)
77

88
Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit.
9+
10+
## Licensing
11+
12+
This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE).

api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ func (a *apiError) Code() int32 {
3535

3636
// MarshalJSON implements the JSON encoding interface
3737
func (a apiError) MarshalJSON() ([]byte, error) {
38-
return json.Marshal(map[string]interface{}{
38+
return json.Marshal(map[string]any{
3939
"code": a.code,
4040
"message": a.message,
4141
})
4242
}
4343

4444
// New creates a new API error with a code and a message
45-
func New(code int32, message string, args ...interface{}) Error {
45+
func New(code int32, message string, args ...any) Error {
4646
if len(args) > 0 {
4747
return &apiError{
4848
code: code,
@@ -56,7 +56,7 @@ func New(code int32, message string, args ...interface{}) Error {
5656
}
5757

5858
// NotFound creates a new not found error
59-
func NotFound(message string, args ...interface{}) Error {
59+
func NotFound(message string, args ...any) Error {
6060
if message == "" {
6161
message = "Not found"
6262
}
@@ -86,7 +86,7 @@ func (m *MethodNotAllowedError) Code() int32 {
8686

8787
// MarshalJSON implements the JSON encoding interface
8888
func (m MethodNotAllowedError) MarshalJSON() ([]byte, error) {
89-
return json.Marshal(map[string]interface{}{
89+
return json.Marshal(map[string]any{
9090
"code": m.code,
9191
"message": m.message,
9292
"allowed": m.Allowed,

api_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"strings"
1313
"testing"
1414

15-
"github.com/stretchr/testify/assert"
16-
"github.com/stretchr/testify/require"
15+
"github.com/go-openapi/testify/v2/assert"
16+
"github.com/go-openapi/testify/v2/require"
1717
)
1818

1919
type customError struct {

auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package errors
66
import (
77
"testing"
88

9-
"github.com/stretchr/testify/assert"
9+
"github.com/go-openapi/testify/v2/assert"
1010
)
1111

1212
func TestUnauthenticated(t *testing.T) {

go.mod

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
module github.com/go-openapi/errors
22

3-
require github.com/stretchr/testify v1.11.1
4-
5-
require (
6-
github.com/davecgh/go-spew v1.1.1 // indirect
7-
github.com/kr/text v0.2.0 // indirect
8-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
9-
github.com/pmezard/go-difflib v1.0.0 // indirect
10-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
11-
gopkg.in/yaml.v3 v3.0.1 // indirect
12-
)
3+
require github.com/go-openapi/testify/v2 v2.0.2
134

145
go 1.24.0

go.sum

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
5-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
6-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
7-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
8-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
9-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
10-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
11-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12-
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
13-
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
14-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
16-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
18-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1+
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
2+
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=

headers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ type Validation struct { //nolint: errname
1414
code int32
1515
Name string
1616
In string
17-
Value interface{}
17+
Value any
1818
message string
19-
Values []interface{}
19+
Values []any
2020
}
2121

2222
func (e *Validation) Error() string {
@@ -30,7 +30,7 @@ func (e *Validation) Code() int32 {
3030

3131
// MarshalJSON implements the JSON encoding interface
3232
func (e Validation) MarshalJSON() ([]byte, error) {
33-
return json.Marshal(map[string]interface{}{
33+
return json.Marshal(map[string]any{
3434
"code": e.code,
3535
"message": e.message,
3636
"in": e.In,
@@ -61,7 +61,7 @@ const (
6161

6262
// InvalidContentType error for an invalid content type
6363
func InvalidContentType(value string, allowed []string) *Validation {
64-
values := make([]interface{}, 0, len(allowed))
64+
values := make([]any, 0, len(allowed))
6565
for _, v := range allowed {
6666
values = append(values, v)
6767
}
@@ -77,7 +77,7 @@ func InvalidContentType(value string, allowed []string) *Validation {
7777

7878
// InvalidResponseFormat error for an unacceptable response format request
7979
func InvalidResponseFormat(value string, allowed []string) *Validation {
80-
values := make([]interface{}, 0, len(allowed))
80+
values := make([]any, 0, len(allowed))
8181
for _, v := range allowed {
8282
values = append(values, v)
8383
}

middleware_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package errors
66
import (
77
"testing"
88

9-
"github.com/stretchr/testify/assert"
9+
"github.com/go-openapi/testify/v2/assert"
1010
)
1111

1212
func TestAPIVerificationFailed(t *testing.T) {

parsing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (e ParseError) MarshalJSON() ([]byte, error) {
5252
if e.Reason != nil {
5353
reason = e.Reason.Error()
5454
}
55-
return json.Marshal(map[string]interface{}{
55+
return json.Marshal(map[string]any{
5656
"code": e.code,
5757
"message": e.message,
5858
"in": e.In,

parsing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"errors"
99
"testing"
1010

11-
"github.com/stretchr/testify/assert"
11+
"github.com/go-openapi/testify/v2/assert"
1212
)
1313

1414
func TestParseError(t *testing.T) {

0 commit comments

Comments
 (0)