mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
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 > ...
This commit is contained in:
parent
7e1a5a0ea8
commit
6c18d0ec2e
@ -350,14 +350,14 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
|
||||
// decode (deserialize) the encoded data back into an object
|
||||
obj2, err := runtime.Decode(codec, data)
|
||||
if err != nil {
|
||||
t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %#v", name, err, codec, dataAsString(data), dump.Pretty(object))
|
||||
t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %s", name, err, codec, dataAsString(data), dump.Pretty(object))
|
||||
panic("failed")
|
||||
}
|
||||
|
||||
// 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, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2))
|
||||
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))
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user