Simple refactor for ease of readability

runtime.DefaultCodec -> latest.Codec
This commit is contained in:
Clayton Coleman
2014-09-16 15:56:26 -04:00
parent 10f68902f6
commit fe614aeda2
21 changed files with 69 additions and 69 deletions

View File

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