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