@@ -4,17 +4,26 @@ import (
4
4
"encoding/json"
5
5
"io"
6
6
"os"
7
+ "reflect"
7
8
"testing"
8
9
"time"
9
10
10
11
"github.com/go-openapi/jsonreference"
12
+ "github.com/google/go-cmp/cmp"
11
13
fuzz "github.com/google/gofuzz"
12
14
openapi_v2 "github.com/googleapis/gnostic/openapiv2"
13
15
"github.com/stretchr/testify/assert"
14
16
"github.com/stretchr/testify/require"
15
17
"google.golang.org/protobuf/proto"
16
18
)
17
19
20
+ var SpecV2DiffOptions = []cmp.Option {
21
+ // cmp.Diff panics on Ref since jsonreference.Ref uses unexported fields
22
+ cmp .Comparer (func (a Ref , b Ref ) bool {
23
+ return a .String () == b .String ()
24
+ }),
25
+ }
26
+
18
27
func gnosticCommonTest (t testing.TB , fuzzer * fuzz.Fuzzer ) {
19
28
fuzzer .Funcs (
20
29
func (v * * Paths , c fuzz.Continue ) {
@@ -327,11 +336,15 @@ func gnosticCommonTest(t testing.TB, fuzzer *fuzz.Fuzzer) {
327
336
328
337
actual := Swagger {}
329
338
require .NoError (t , actual .FromGnostic (gnosticSpec ))
330
- require .EqualValues (t , expected , actual )
339
+ if ! reflect .DeepEqual (expected , actual ) {
340
+ t .Fatal (cmp .Diff (expected , actual , SpecV2DiffOptions ... ))
341
+ }
331
342
332
343
newJsonBytes , err := json .Marshal (actual )
333
344
require .NoError (t , err )
334
- require .Equal (t , string (jsonBytes ), string (newJsonBytes ))
345
+ if ! reflect .DeepEqual (jsonBytes , newJsonBytes ) {
346
+ t .Fatal (cmp .Diff (string (jsonBytes ), string (newJsonBytes ), SpecV2DiffOptions ... ))
347
+ }
335
348
}
336
349
337
350
func TestGnosticConversionSmallDeterministic (t * testing.T ) {
0 commit comments