mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix k8s json package import name
This commit is contained in:
parent
23b4690d00
commit
0623068f6c
@ -19,7 +19,7 @@ package testing
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
gojson "encoding/json"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
@ -37,7 +37,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
k8s_json "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@ -437,7 +437,7 @@ func BenchmarkEncodeJSONMarshal(b *testing.B) {
|
||||
width := len(items)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
if _, err := json.Marshal(&items[i%width]); err != nil {
|
||||
if _, err := gojson.Marshal(&items[i%width]); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -529,7 +529,7 @@ func BenchmarkDecodeIntoJSON(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
obj := v1.Pod{}
|
||||
if err := json.Unmarshal(encoded[i%width], &obj); err != nil {
|
||||
if err := gojson.Unmarshal(encoded[i%width], &obj); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -579,7 +579,7 @@ func BenchmarkDecodeIntoJSONCodecGenConfigCompatibleWithStandardLibrary(b *testi
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
iter := k8s_json.CaseSensitiveJsonIterator()
|
||||
iter := json.CaseSensitiveJsonIterator()
|
||||
for i := 0; i < b.N; i++ {
|
||||
obj := v1.Pod{}
|
||||
if err := iter.Unmarshal(encoded[i%width], &obj); err != nil {
|
||||
|
@ -17,11 +17,11 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
gojson "encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
k8s_json "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
)
|
||||
|
||||
type GroupVersionHolder struct {
|
||||
@ -40,14 +40,14 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
|
||||
for _, c := range cases {
|
||||
var result GroupVersionHolder
|
||||
// test golang lib's JSON codec
|
||||
if err := json.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
if err := gojson.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
t.Errorf("JSON codec failed to unmarshal input '%v': %v", c.input, err)
|
||||
}
|
||||
if !reflect.DeepEqual(result.GV, c.expect) {
|
||||
t.Errorf("JSON codec failed to unmarshal input '%s': expected %+v, got %+v", c.input, c.expect, result.GV)
|
||||
}
|
||||
// test the json-iterator codec
|
||||
iter := k8s_json.CaseSensitiveJsonIterator()
|
||||
iter := json.CaseSensitiveJsonIterator()
|
||||
if err := iter.Unmarshal(c.input, &result); err != nil {
|
||||
t.Errorf("json-iterator codec failed to unmarshal input '%v': %v", c.input, err)
|
||||
}
|
||||
@ -68,7 +68,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) {
|
||||
|
||||
for _, c := range cases {
|
||||
input := GroupVersionHolder{c.input}
|
||||
result, err := json.Marshal(&input)
|
||||
result, err := gojson.Marshal(&input)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to marshal input '%v': %v", input, err)
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
gojson "encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
k8s_json "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
)
|
||||
|
||||
func TestVerbsUgorjiMarshalJSON(t *testing.T) {
|
||||
func TestVerbsMarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
input APIResource
|
||||
result string
|
||||
@ -35,7 +35,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
result, err := json.Marshal(&c.input)
|
||||
result, err := gojson.Marshal(&c.input)
|
||||
if err != nil {
|
||||
t.Errorf("[%d] Failed to marshal input: '%v': %v", i, c.input, err)
|
||||
}
|
||||
@ -45,7 +45,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
|
||||
func TestVerbsJsonIterUnmarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
result APIResource
|
||||
@ -56,7 +56,7 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
|
||||
{`{"verbs":["delete"]}`, APIResource{Verbs: Verbs([]string{"delete"})}},
|
||||
}
|
||||
|
||||
iter := k8s_json.CaseSensitiveJsonIterator()
|
||||
iter := json.CaseSensitiveJsonIterator()
|
||||
for i, c := range cases {
|
||||
var result APIResource
|
||||
if err := iter.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
@ -68,8 +68,8 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestUgorjiMarshalJSONWithOmit tests that we don't have regressions regarding nil and empty slices with "omit"
|
||||
func TestUgorjiMarshalJSONWithOmit(t *testing.T) {
|
||||
// TestMarshalJSONWithOmit tests that we don't have regressions regarding nil and empty slices with "omit"
|
||||
func TestMarshalJSONWithOmit(t *testing.T) {
|
||||
cases := []struct {
|
||||
input LabelSelector
|
||||
result string
|
||||
@ -80,7 +80,7 @@ func TestUgorjiMarshalJSONWithOmit(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
result, err := json.Marshal(&c.input)
|
||||
result, err := gojson.Marshal(&c.input)
|
||||
if err != nil {
|
||||
t.Errorf("[%d] Failed to marshal input: '%v': %v", i, c.input, err)
|
||||
}
|
||||
@ -103,7 +103,7 @@ func TestVerbsUnmarshalJSON(t *testing.T) {
|
||||
|
||||
for i, c := range cases {
|
||||
var result APIResource
|
||||
if err := json.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
if err := gojson.Unmarshal([]byte(c.input), &result); err != nil {
|
||||
t.Errorf("[%d] Failed to unmarshal input '%v': %v", i, c.input, err)
|
||||
}
|
||||
if !reflect.DeepEqual(result, c.result) {
|
||||
|
Loading…
Reference in New Issue
Block a user