Move pkg/client/unvrsioned#testClient to pkg/client/unversioned/testclient#simple

This commit is contained in:
Chao Xu
2015-12-03 17:22:48 -08:00
parent 8d46df0162
commit 6f0eb521a6
20 changed files with 723 additions and 622 deletions

View File

@@ -14,7 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package unversioned
package unversioned_test
import (
. "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient/simple"
)
import (
"testing"
@@ -31,12 +36,12 @@ func getDSResourceName() string {
func TestListDaemonSets(t *testing.T) {
ns := api.NamespaceAll
c := &testClient{
Request: testRequest{
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, ""),
},
Response: Response{StatusCode: 200,
Response: simple.Response{StatusCode: 200,
Body: &extensions.DaemonSetList{
Items: []extensions.DaemonSet{
{
@@ -62,9 +67,9 @@ func TestListDaemonSets(t *testing.T) {
func TestGetDaemonSet(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
c := &simple.Client{
Request: simple.Request{Method: "GET", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{
@@ -86,10 +91,10 @@ func TestGetDaemonSet(t *testing.T) {
func TestGetDaemonSetWithNoName(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{Error: true}
c := &simple.Client{Error: true}
receivedPod, err := c.Setup(t).Extensions().DaemonSets(ns).Get("")
if (err != nil) && (err.Error() != nameRequiredError) {
t.Errorf("Expected error: %v, but got %v", nameRequiredError, err)
if (err != nil) && (err.Error() != simple.NameRequiredError) {
t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err)
}
c.Validate(t, receivedPod, err)
@@ -100,9 +105,9 @@ func TestUpdateDaemonSet(t *testing.T) {
requestDaemonSet := &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{
@@ -127,9 +132,9 @@ func TestUpdateDaemonSetUpdateStatus(t *testing.T) {
requestDaemonSet := &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo") + "/status", Query: buildQueryValues(nil)},
Response: Response{
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo") + "/status", Query: simple.BuildQueryValues(nil)},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{
@@ -152,9 +157,9 @@ func TestUpdateDaemonSetUpdateStatus(t *testing.T) {
func TestDeleteDaemon(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
c := &simple.Client{
Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200},
}
err := c.Setup(t).Extensions().DaemonSets(ns).Delete("foo")
c.Validate(t, nil, err)
@@ -165,9 +170,9 @@ func TestCreateDaemonSet(t *testing.T) {
requestDaemonSet := &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "foo"},
}
c := &testClient{
Request: testRequest{Method: "POST", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, ""), Body: requestDaemonSet, Query: buildQueryValues(nil)},
Response: Response{
c := &simple.Client{
Request: simple.Request{Method: "POST", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, ""), Body: requestDaemonSet, Query: simple.BuildQueryValues(nil)},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{