apimachinery: fail early with deepcopy problems during roundtrip tests

This commit is contained in:
Dr. Stefan Schimanski 2017-07-24 10:24:05 +02:00
parent 3d94338e44
commit 14c50f3c3a

View File

@ -276,6 +276,12 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
object = copied.(runtime.Object)
name := reflect.TypeOf(object).Elem().Name()
// catch deepcopy errors early
if !apiequality.Semantic.DeepEqual(original, object) {
t.Errorf("%v: DeepCopy did not lead to equal object, diff: %v", name, diff.ObjectReflectDiff(original, object))
return
}
// encode (serialize) the deep copy using the provided codec
data, err := runtime.Encode(codec, object)
if err != nil {