Task -> Pod #4, the final chapter

This commit is contained in:
Brendan Burns
2014-06-08 23:00:12 -07:00
parent 6018497174
commit 5cb4444176
8 changed files with 98 additions and 98 deletions

View File

@@ -144,7 +144,7 @@ func DecodeLabelQuery(labelQuery string) map[string]string {
// ListPods takes a label query, and returns the list of pods that match that query
func (client Client) ListPods(labelQuery map[string]string) (api.PodList, error) {
path := "tasks"
path := "pods"
if labelQuery != nil && len(labelQuery) > 0 {
path += "?labels=" + EncodeLabelQuery(labelQuery)
}
@@ -156,13 +156,13 @@ func (client Client) ListPods(labelQuery map[string]string) (api.PodList, error)
// GetPod takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
func (client Client) GetPod(name string) (api.Pod, error) {
var result api.Pod
_, err := client.rawRequest("GET", "tasks/"+name, nil, &result)
_, err := client.rawRequest("GET", "pods/"+name, nil, &result)
return result, err
}
// DeletePod takes the name of the pod, and returns an error if one occurs
func (client Client) DeletePod(name string) error {
_, err := client.rawRequest("DELETE", "tasks/"+name, nil, nil)
_, err := client.rawRequest("DELETE", "pods/"+name, nil, nil)
return err
}
@@ -171,7 +171,7 @@ func (client Client) CreatePod(pod api.Pod) (api.Pod, error) {
var result api.Pod
body, err := json.Marshal(pod)
if err == nil {
_, err = client.rawRequest("POST", "tasks", bytes.NewBuffer(body), &result)
_, err = client.rawRequest("POST", "pods", bytes.NewBuffer(body), &result)
}
return result, err
}
@@ -181,7 +181,7 @@ func (client Client) UpdatePod(pod api.Pod) (api.Pod, error) {
var result api.Pod
body, err := json.Marshal(pod)
if err == nil {
_, err = client.rawRequest("PUT", "tasks/"+pod.ID, bytes.NewBuffer(body), &result)
_, err = client.rawRequest("PUT", "pods/"+pod.ID, bytes.NewBuffer(body), &result)
}
return result, err
}

View File

@@ -50,7 +50,7 @@ func TestListEmptyPods(t *testing.T) {
Host: testServer.URL,
}
podList, err := client.ListPods(nil)
fakeHandler.ValidateRequest(t, makeUrl("/tasks"), "GET", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods"), "GET", nil)
if err != nil {
t.Errorf("Unexpected error in listing pods: %#v", err)
}
@@ -84,7 +84,7 @@ func TestListPods(t *testing.T) {
Host: testServer.URL,
}
receivedPodList, err := client.ListPods(nil)
fakeHandler.ValidateRequest(t, makeUrl("/tasks"), "GET", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods"), "GET", nil)
if err != nil {
t.Errorf("Unexpected error in listing pods: %#v", err)
}
@@ -119,7 +119,7 @@ func TestListPodsLabels(t *testing.T) {
}
query := map[string]string{"foo": "bar", "name": "baz"}
receivedPodList, err := client.ListPods(query)
fakeHandler.ValidateRequest(t, makeUrl("/tasks"), "GET", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods"), "GET", nil)
queryString := fakeHandler.RequestReceived.URL.Query().Get("labels")
queryString, _ = url.QueryUnescape(queryString)
// TODO(bburns) : This assumes some ordering in serialization that might not always
@@ -156,7 +156,7 @@ func TestGetPod(t *testing.T) {
Host: testServer.URL,
}
receivedPod, err := client.GetPod("foo")
fakeHandler.ValidateRequest(t, makeUrl("/tasks/foo"), "GET", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods/foo"), "GET", nil)
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}
@@ -176,7 +176,7 @@ func TestDeletePod(t *testing.T) {
Host: testServer.URL,
}
err := client.DeletePod("foo")
fakeHandler.ValidateRequest(t, makeUrl("/tasks/foo"), "DELETE", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods/foo"), "DELETE", nil)
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}
@@ -203,7 +203,7 @@ func TestCreatePod(t *testing.T) {
Host: testServer.URL,
}
receivedPod, err := client.CreatePod(requestPod)
fakeHandler.ValidateRequest(t, makeUrl("/tasks"), "POST", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods"), "POST", nil)
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}
@@ -234,7 +234,7 @@ func TestUpdatePod(t *testing.T) {
Host: testServer.URL,
}
receivedPod, err := client.UpdatePod(requestPod)
fakeHandler.ValidateRequest(t, makeUrl("/tasks/foo"), "PUT", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods/foo"), "PUT", nil)
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}

View File

@@ -203,7 +203,7 @@ func TestCreateReplica(t *testing.T) {
// DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
//}
// TODO: fix this so that it validates the body.
fakeHandler.ValidateRequest(t, makeUrl("/tasks"), "POST", nil)
fakeHandler.ValidateRequest(t, makeUrl("/pods"), "POST", nil)
}
func TestHandleWatchResponseNotSet(t *testing.T) {