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

@@ -38,12 +38,12 @@ func TestNewREST(t *testing.T) {
PodID: "foo",
Host: "bar",
}
body, err := runtime.DefaultCodec.Encode(binding)
body, err := latest.Codec.Encode(binding)
if err != nil {
t.Fatalf("Unexpected encode error %v", err)
}
obj := b.New()
err = runtime.DefaultCodec.DecodeInto(body, obj)
err = latest.Codec.DecodeInto(body, obj)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}

View File

@@ -113,13 +113,13 @@ func TestControllerDecode(t *testing.T) {
ID: "foo",
},
}
body, err := runtime.DefaultCodec.Encode(controller)
body, err := latest.Codec.Encode(controller)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
controllerOut := storage.New()
if err := runtime.DefaultCodec.DecodeInto(body, controllerOut); err != nil {
if err := latest.Codec.DecodeInto(body, controllerOut); err != nil {
t.Errorf("unexpected error: %v", err)
}

View File

@@ -45,7 +45,7 @@ func NewRegistry(client tools.EtcdClient) *Registry {
registry := &Registry{
EtcdHelper: tools.EtcdHelper{
client,
runtime.DefaultCodec,
latest.Codec,
runtime.DefaultResourceVersioner,
},
}

View File

@@ -108,7 +108,7 @@ func TestEtcdCreatePod(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var pod api.Pod
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -122,7 +122,7 @@ func TestEtcdCreatePod(t *testing.T) {
t.Errorf("unexpected error: %v", err)
}
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests)
}
@@ -235,7 +235,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var pod api.Pod
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -249,7 +249,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
t.Errorf("unexpected error: %v", err)
}
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests)
}
@@ -300,7 +300,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var pod api.Pod
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -314,7 +314,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
t.Errorf("unexpected error: %v", err)
}
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests)
}
@@ -350,7 +350,7 @@ func TestEtcdDeletePod(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var manifests api.ContainerManifestList
runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &manifests)
latest.Codec.DecodeInto([]byte(response.Node.Value), &manifests)
if len(manifests.Items) != 0 {
t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value)
}
@@ -388,7 +388,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var manifests api.ContainerManifestList
runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &manifests)
latest.Codec.DecodeInto([]byte(response.Node.Value), &manifests)
if len(manifests.Items) != 1 {
t.Fatalf("Unexpected manifest set: %#v, expected empty", manifests)
}
@@ -607,7 +607,7 @@ func TestEtcdCreateController(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var ctrl api.ReplicationController
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &ctrl)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &ctrl)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -699,7 +699,7 @@ func TestEtcdCreateService(t *testing.T) {
}
var service api.Service
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &service)
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &service)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -874,7 +874,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
t.Fatalf("Unexpected error %v", err)
}
var endpointsOut api.Endpoints
err = runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &endpointsOut)
err = latest.Codec.DecodeInto([]byte(response.Node.Value), &endpointsOut)
if !reflect.DeepEqual(endpoints, endpointsOut) {
t.Errorf("Unexpected endpoints: %#v, expected %#v", endpointsOut, endpoints)
}

View File

@@ -201,13 +201,13 @@ func TestPodDecode(t *testing.T) {
ID: "foo",
},
}
body, err := runtime.DefaultCodec.Encode(expected)
body, err := latest.Codec.Encode(expected)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
actual := storage.New()
if err := runtime.DefaultCodec.DecodeInto(body, actual); err != nil {
if err := latest.Codec.DecodeInto(body, actual); err != nil {
t.Errorf("unexpected error: %v", err)
}