refactor testapi and test scripts to prepare for multiple API groups.
This commit is contained in:
@@ -33,7 +33,7 @@ func TestListControllers(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
Path: testapi.ResourcePath(getRCResourceName(), ns, ""),
|
||||
Path: testapi.Default.ResourcePath(getRCResourceName(), ns, ""),
|
||||
},
|
||||
Response: Response{StatusCode: 200,
|
||||
Body: &api.ReplicationControllerList{
|
||||
@@ -55,7 +55,7 @@ func TestListControllers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedControllerList, err := c.Setup().ReplicationControllers(ns).List(labels.Everything())
|
||||
receivedControllerList, err := c.Setup(t).ReplicationControllers(ns).List(labels.Everything())
|
||||
c.Validate(t, receivedControllerList, err)
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func TestListControllers(t *testing.T) {
|
||||
func TestGetController(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "GET", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
@@ -81,14 +81,14 @@ func TestGetController(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().ReplicationControllers(ns).Get("foo")
|
||||
receivedController, err := c.Setup(t).ReplicationControllers(ns).Get("foo")
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
func TestGetControllerWithNoName(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{Error: true}
|
||||
receivedPod, err := c.Setup().ReplicationControllers(ns).Get("")
|
||||
receivedPod, err := c.Setup(t).ReplicationControllers(ns).Get("")
|
||||
if (err != nil) && (err.Error() != nameRequiredError) {
|
||||
t.Errorf("Expected error: %v, but got %v", nameRequiredError, err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestUpdateController(t *testing.T) {
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "PUT", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
@@ -120,17 +120,17 @@ func TestUpdateController(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().ReplicationControllers(ns).Update(requestController)
|
||||
receivedController, err := c.Setup(t).ReplicationControllers(ns).Update(requestController)
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
func TestDeleteController(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: 200},
|
||||
}
|
||||
err := c.Setup().ReplicationControllers(ns).Delete("foo")
|
||||
err := c.Setup(t).ReplicationControllers(ns).Delete("foo")
|
||||
c.Validate(t, nil, err)
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ func TestCreateController(t *testing.T) {
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: testapi.ResourcePath(getRCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "POST", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
@@ -158,6 +158,6 @@ func TestCreateController(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().ReplicationControllers(ns).Create(requestController)
|
||||
receivedController, err := c.Setup(t).ReplicationControllers(ns).Create(requestController)
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user