Skip to content

Commit 160885f

Browse files
benluddyk8s-publishing-bot
authored andcommitted
Fix fmt verbs for strings in roundtrip test errors.
Some of the calls to t.Errorf from apitesting/roundtrip use the %#v verb (Go-syntax representation) for string arguments that are have already been formatted for legibility by something like like cmp.Diff. Quoting and escaping newlines in these strings makes them harder to read, like this: > ... > "(*storage.CSIDriver)({\n TypeMeta: (v1.TypeMeta) {\n Kind: (string) \"\",\n APIVersion: (string) > \"\"\n },\n ObjectMeta: (v1.ObjectMeta) {\n Name: (string) (len=15) \"犱âM邽[ǎ*ʄ\",\n > ... Kubernetes-commit: 6c18d0ec2e01c69c79a005e8ce4194567b945cc2
1 parent ef4453d commit 160885f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/api/apitesting/roundtrip/roundtrip.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,14 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
350350
// decode (deserialize) the encoded data back into an object
351351
obj2, err := runtime.Decode(codec, data)
352352
if err != nil {
353-
t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %#v", name, err, codec, dataAsString(data), dump.Pretty(object))
353+
t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %s", name, err, codec, dataAsString(data), dump.Pretty(object))
354354
panic("failed")
355355
}
356356

357357
// ensure that the object produced from decoding the encoded data is equal
358358
// to the original object
359359
if !apiequality.Semantic.DeepEqual(original, obj2) {
360-
t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2))
360+
t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%s\n\nEncoded:\n\n%s\n\nFinal:\n\n%s", name, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2))
361361
return
362362
}
363363

0 commit comments

Comments
 (0)