add v1 tests to tests in kubectl/cmd/*

This commit is contained in:
Chao Xu
2015-06-03 11:54:50 -07:00
parent 1845ca88fc
commit 8885025d25
4 changed files with 202 additions and 55 deletions

View File

@@ -118,26 +118,38 @@ func TestPodAndContainer(t *testing.T) {
func TestExec(t *testing.T) {
tests := []struct {
name, version, podPath, execPath, container string
nsInQuery bool
pod *api.Pod
execErr bool
}{
{
name: "v1beta3 - pod exec",
version: "v1beta3",
podPath: "/api/v1beta3/namespaces/test/pods/foo",
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
nsInQuery: false,
pod: execPod(),
name: "v1beta3 - pod exec",
version: "v1beta3",
podPath: "/api/v1beta3/namespaces/test/pods/foo",
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
pod: execPod(),
},
{
name: "v1beta3 - pod exec error",
version: "v1beta3",
podPath: "/api/v1beta3/namespaces/test/pods/foo",
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
nsInQuery: false,
pod: execPod(),
execErr: true,
name: "v1beta3 - pod exec error",
version: "v1beta3",
podPath: "/api/v1beta3/namespaces/test/pods/foo",
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
pod: execPod(),
execErr: true,
},
{
name: "v1 - pod exec",
version: "v1",
podPath: "/api/v1/namespaces/test/pods/foo",
execPath: "/api/v1/namespaces/test/pods/foo/exec",
pod: execPod(),
},
{
name: "v1 - pod exec error",
version: "v1",
podPath: "/api/v1/namespaces/test/pods/foo",
execPath: "/api/v1/namespaces/test/pods/foo/exec",
pod: execPod(),
execErr: true,
},
}
for _, test := range tests {
@@ -147,11 +159,6 @@ func TestExec(t *testing.T) {
Client: client.HTTPClientFunc(func(req *http.Request) (*http.Response, error) {
switch p, m := req.URL.Path, req.Method; {
case p == test.podPath && m == "GET":
if test.nsInQuery {
if ns := req.URL.Query().Get("namespace"); ns != "test" {
t.Errorf("%s: did not get expected namespace: %s\n", test.name, ns)
}
}
body := objBody(codec, test.pod)
return &http.Response{StatusCode: 200, Body: body}, nil
default: