Rename Codec and ResourceVersioner to add Default in front, to allow for types of those names

This commit is contained in:
Daniel Smith
2014-09-05 18:47:09 -07:00
parent 828b70abb9
commit 1c2b65788d
29 changed files with 121 additions and 96 deletions

View File

@@ -115,13 +115,13 @@ func runTest(t *testing.T, source runtime.Object) {
j.SetKind("")
j.SetAPIVersion("")
data, err := runtime.Codec.Encode(source)
data, err := runtime.DefaultCodec.Encode(source)
if err != nil {
t.Errorf("%v: %v (%#v)", name, err, source)
return
}
obj2, err := runtime.Codec.Decode(data)
obj2, err := runtime.DefaultCodec.Decode(data)
if err != nil {
t.Errorf("%v: %v", name, err)
return
@@ -132,7 +132,7 @@ func runTest(t *testing.T, source runtime.Object) {
}
}
obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface().(runtime.Object)
err = runtime.Codec.DecodeInto(data, obj3)
err = runtime.DefaultCodec.DecodeInto(data, obj3)
if err != nil {
t.Errorf("2: %v: %v", name, err)
return
@@ -174,8 +174,8 @@ func TestEncode_Ptr(t *testing.T) {
Labels: map[string]string{"name": "foo"},
}
obj := runtime.Object(pod)
data, err := runtime.Codec.Encode(obj)
obj2, err2 := runtime.Codec.Decode(data)
data, err := runtime.DefaultCodec.Encode(obj)
obj2, err2 := runtime.DefaultCodec.Decode(data)
if err != nil || err2 != nil {
t.Fatalf("Failure: '%v' '%v'", err, err2)
}
@@ -189,11 +189,11 @@ func TestEncode_Ptr(t *testing.T) {
func TestBadJSONRejection(t *testing.T) {
badJSONMissingKind := []byte(`{ }`)
if _, err := runtime.Codec.Decode(badJSONMissingKind); err == nil {
if _, err := runtime.DefaultCodec.Decode(badJSONMissingKind); err == nil {
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
}
badJSONUnknownType := []byte(`{"kind": "bar"}`)
if _, err1 := runtime.Codec.Decode(badJSONUnknownType); err1 == nil {
if _, err1 := runtime.DefaultCodec.Decode(badJSONUnknownType); err1 == nil {
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
}
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)