mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-07 16:45:35 +00:00
refactor testapi and test scripts to prepare for multiple API groups.
This commit is contained in:
@@ -20,8 +20,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/expapi"
|
||||
"k8s.io/kubernetes/pkg/expapi/testapi"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestListDaemons(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
Path: testapi.ResourcePath(getDCResourceName(), ns, ""),
|
||||
Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, ""),
|
||||
},
|
||||
Response: Response{StatusCode: 200,
|
||||
Body: &expapi.DaemonList{
|
||||
@@ -55,7 +55,7 @@ func TestListDaemons(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedControllerList, err := c.Setup().Experimental().Daemons(ns).List(labels.Everything())
|
||||
receivedControllerList, err := c.Setup(t).Experimental().Daemons(ns).List(labels.Everything())
|
||||
c.Validate(t, receivedControllerList, err)
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func TestListDaemons(t *testing.T) {
|
||||
func TestGetDaemon(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: testapi.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "GET", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &expapi.Daemon{
|
||||
@@ -80,14 +80,14 @@ func TestGetDaemon(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().Experimental().Daemons(ns).Get("foo")
|
||||
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Get("foo")
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
func TestGetDaemonWithNoName(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{Error: true}
|
||||
receivedPod, err := c.Setup().Experimental().Daemons(ns).Get("")
|
||||
receivedPod, err := c.Setup(t).Experimental().Daemons(ns).Get("")
|
||||
if (err != nil) && (err.Error() != nameRequiredError) {
|
||||
t.Errorf("Expected error: %v, but got %v", nameRequiredError, err)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func TestUpdateDaemon(t *testing.T) {
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "PUT", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &expapi.Daemon{
|
||||
@@ -118,17 +118,17 @@ func TestUpdateDaemon(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().Experimental().Daemons(ns).Update(requestController)
|
||||
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Update(requestController)
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
func TestDeleteDaemon(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: 200},
|
||||
}
|
||||
err := c.Setup().Experimental().Daemons(ns).Delete("foo")
|
||||
err := c.Setup(t).Experimental().Daemons(ns).Delete("foo")
|
||||
c.Validate(t, nil, err)
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestCreateDaemon(t *testing.T) {
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: testapi.ResourcePath(getDCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
|
||||
Request: testRequest{Method: "POST", Path: testapi.Experimental.ResourcePath(getDCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &expapi.Daemon{
|
||||
@@ -155,6 +155,6 @@ func TestCreateDaemon(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
receivedController, err := c.Setup().Experimental().Daemons(ns).Create(requestController)
|
||||
receivedController, err := c.Setup(t).Experimental().Daemons(ns).Create(requestController)
|
||||
c.Validate(t, receivedController, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user