mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
Compact pretty-printed compatibility fixtures when decoding
This commit is contained in:
parent
17111241ba
commit
74ca1b953a
@ -18,6 +18,7 @@ package roundtrip
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
gojson "encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -336,8 +337,14 @@ func (c *CompatibilityTestOptions) runCurrentVersionTest(t *testing.T, gvk schem
|
||||
t.Fatal(err)
|
||||
}
|
||||
{
|
||||
// compact before decoding since embedded RawExtension fields retain indenting
|
||||
compacted := &bytes.Buffer{}
|
||||
if err := gojson.Compact(compacted, actualJSON); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
jsonDecoded := emptyObj.DeepCopyObject()
|
||||
jsonDecoded, _, err = c.JSON.Decode(actualJSON, &gvk, jsonDecoded)
|
||||
jsonDecoded, _, err = c.JSON.Decode(compacted.Bytes(), &gvk, jsonDecoded)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
} else if !apiequality.Semantic.DeepEqual(expectedObject, jsonDecoded) {
|
||||
@ -420,8 +427,14 @@ func (c *CompatibilityTestOptions) runPreviousVersionTest(t *testing.T, gvk sche
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// compact before decoding since embedded RawExtension fields retain indenting
|
||||
compacted := &bytes.Buffer{}
|
||||
if err := gojson.Compact(compacted, jsonBeforeRoundTrip); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
jsonDecoded := emptyObj.DeepCopyObject()
|
||||
jsonDecoded, _, err = c.JSON.Decode(jsonBeforeRoundTrip, &gvk, jsonDecoded)
|
||||
jsonDecoded, _, err = c.JSON.Decode(compacted.Bytes(), &gvk, jsonDecoded)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user