@@ -31,6 +31,7 @@ import (
3131 "github.com/stretchr/testify/require"
3232 "google.golang.org/protobuf/proto"
3333 "gopkg.in/yaml.v3"
34+ jsontesting "k8s.io/kube-openapi/pkg/util/jsontesting"
3435 . "k8s.io/kube-openapi/pkg/validation/spec"
3536)
3637
@@ -43,7 +44,7 @@ func gnosticCommonTest(t testing.TB, fuzzer *fuzz.Fuzzer) {
4344 fuzzer .Fuzz (& expected )
4445
4546 // Convert to gnostic via JSON to compare
46- jsonBytes , err := json . Marshal ( expected )
47+ jsonBytes , err := expected . MarshalNext ( )
4748 require .NoError (t , err )
4849
4950 t .Log ("Specimen" , string (jsonBytes ))
@@ -59,10 +60,10 @@ func gnosticCommonTest(t testing.TB, fuzzer *fuzz.Fuzzer) {
5960 t .Fatal (cmp .Diff (expected , actual , SwaggerDiffOptions ... ))
6061 }
6162
62- newJsonBytes , err := json . Marshal ( actual )
63+ newJsonBytes , err := actual . MarshalNext ( )
6364 require .NoError (t , err )
64- if ! reflect . DeepEqual (jsonBytes , newJsonBytes ) {
65- t .Fatal (cmp . Diff ( string ( jsonBytes ), string ( newJsonBytes ), SwaggerDiffOptions ... ) )
65+ if err := jsontesting . JsonCompare (jsonBytes , newJsonBytes ); err != nil {
66+ t .Fatal (err )
6667 }
6768}
6869
@@ -518,19 +519,19 @@ func TestCommonDataLoss(t *testing.T) {
518519
519520 // Make sure that they were exactly the same, except for the data loss
520521 // by checking JSON encodes the some
521- badConvertedJSON , err := json . Marshal ( badConverted )
522+ badConvertedJSON , err := badConverted . MarshalNext ( )
522523 if err != nil {
523524 t .Error (err )
524525 return
525526 }
526527
527- fixedConvertedJSON , err := json . Marshal ( fixedConverted )
528+ fixedConvertedJSON , err := fixedConverted . MarshalNext ( )
528529 if err != nil {
529530 t .Error (err )
530531 return
531532 }
532533
533- fixedDirectJSON , err := json . Marshal ( fixedDirect )
534+ fixedDirectJSON , err := fixedDirect . MarshalNext ( )
534535 if err != nil {
535536 t .Error (err )
536537 return
@@ -580,13 +581,13 @@ func TestBadStatusCode(t *testing.T) {
580581
581582 // Make sure that they were exactly the same, except for the data loss
582583 // by checking JSON encodes the some
583- badConvertedJSON , err := json . Marshal ( badConverted )
584+ badConvertedJSON , err := badConverted . MarshalNext ( )
584585 if err != nil {
585586 t .Error (err )
586587 return
587588 }
588589
589- droppedConvertedJSON , err := json . Marshal ( droppedConverted )
590+ droppedConvertedJSON , err := droppedConverted . MarshalNext ( )
590591 if err != nil {
591592 t .Error (err )
592593 return
0 commit comments