Merge pull request #51204 from nikhita/fix-roundtrip-errors

Automatic merge from submit-queue (batch tested with PRs 47115, 51196, 51204, 51208, 51206)

roundtrip: fix error messages

The error messages had some typos due to which it generated false positives. (encountered in #47263) 

**Release note**:

```release-note
NONE
```

/cc @sttts
This commit is contained in:
Kubernetes Submit Queue 2017-08-24 07:20:10 -07:00 committed by GitHub
commit 761fb34e3d

View File

@ -270,6 +270,12 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// deep copy the original object
object = object.DeepCopyObject()
name := reflect.TypeOf(object).Elem().Name()
if !apiequality.Semantic.DeepEqual(original, object) {
t.Errorf("%v: DeepCopy altered the object, diff: %v", name, diff.ObjectReflectDiff(original, object))
t.Errorf("%s", spew.Sdump(original))
t.Errorf("%s", spew.Sdump(object))
return
}
// catch deepcopy errors early
if !apiequality.Semantic.DeepEqual(original, object) {
@ -323,7 +329,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// ensure that the object produced from decoding the encoded data is equal
// to the original object
if !apiequality.Semantic.DeepEqual(original, obj2) {
t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectReflectDiff(object, obj2), codec, printer.Sprintf("%#v", object), dataAsString(data), printer.Sprintf("%#v", obj2))
t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectReflectDiff(original, obj2), codec, printer.Sprintf("%#v", original), dataAsString(data), printer.Sprintf("%#v", obj2))
return
}
@ -370,7 +376,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// NOTE: we use the encoding+decoding here as an alternative, guaranteed deep-copy to compare against.
fuzzer.ValueFuzz(object)
if !apiequality.Semantic.DeepEqual(original, obj3) {
t.Errorf("%v: fuzzing a copy altered the original, diff: %v", name, diff.ObjectReflectDiff(original, object))
t.Errorf("%v: fuzzing a copy altered the original, diff: %v", name, diff.ObjectReflectDiff(original, obj3))
return
}
}