Move pkg/client/unvrsioned#testClient to pkg/client/unversioned/testclient#simple
This commit is contained in:
@@ -14,7 +14,9 @@ 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"
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@@ -24,14 +26,15 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/testclient/simple"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
)
|
||||
|
||||
func TestListEmptyPods(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: http.StatusOK, Body: &api.PodList{}},
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil)},
|
||||
Response: simple.Response{StatusCode: http.StatusOK, Body: &api.PodList{}},
|
||||
}
|
||||
podList, err := c.Setup(t).Pods(ns).List(unversioned.ListOptions{})
|
||||
c.Validate(t, podList, err)
|
||||
@@ -39,9 +42,9 @@ func TestListEmptyPods(t *testing.T) {
|
||||
|
||||
func TestListPods(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: http.StatusOK,
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil)},
|
||||
Response: simple.Response{StatusCode: http.StatusOK,
|
||||
Body: &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
@@ -66,12 +69,12 @@ func TestListPods(t *testing.T) {
|
||||
func TestListPodsLabels(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{
|
||||
Method: "GET",
|
||||
Path: testapi.Default.ResourcePath("pods", ns, ""),
|
||||
Query: buildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
|
||||
Response: Response{
|
||||
Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
|
||||
Response: simple.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: &api.PodList{
|
||||
Items: []api.Pod{
|
||||
@@ -91,7 +94,7 @@ func TestListPodsLabels(t *testing.T) {
|
||||
},
|
||||
}
|
||||
c.Setup(t)
|
||||
c.QueryValidator[labelSelectorQueryParamName] = validateLabels
|
||||
c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels
|
||||
selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
|
||||
options := unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{selector}}
|
||||
receivedPodList, err := c.Pods(ns).List(options)
|
||||
@@ -100,9 +103,9 @@ func TestListPodsLabels(t *testing.T) {
|
||||
|
||||
func TestGetPod(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)},
|
||||
Response: simple.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: &api.Pod{
|
||||
Status: api.PodStatus{
|
||||
@@ -123,10 +126,10 @@ func TestGetPod(t *testing.T) {
|
||||
|
||||
func TestGetPodWithNoName(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{Error: true}
|
||||
c := &simple.Client{Error: true}
|
||||
receivedPod, err := c.Setup(t).Pods(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)
|
||||
@@ -134,9 +137,9 @@ func TestGetPodWithNoName(t *testing.T) {
|
||||
|
||||
func TestDeletePod(t *testing.T) {
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: http.StatusOK},
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)},
|
||||
Response: simple.Response{StatusCode: http.StatusOK},
|
||||
}
|
||||
err := c.Setup(t).Pods(ns).Delete("foo", nil)
|
||||
c.Validate(t, nil, err)
|
||||
@@ -155,9 +158,9 @@ func TestCreatePod(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil), Body: requestPod},
|
||||
Response: Response{
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "POST", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil), Body: requestPod},
|
||||
Response: simple.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: requestPod,
|
||||
},
|
||||
@@ -181,9 +184,9 @@ func TestUpdatePod(t *testing.T) {
|
||||
Phase: api.PodRunning,
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
|
||||
Response: Response{StatusCode: http.StatusOK, Body: requestPod},
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)},
|
||||
Response: simple.Response{StatusCode: http.StatusOK, Body: requestPod},
|
||||
}
|
||||
receivedPod, err := c.Setup(t).Pods(ns).Update(requestPod)
|
||||
c.Validate(t, receivedPod, err)
|
||||
@@ -195,8 +198,8 @@ func TestPodGetLogs(t *testing.T) {
|
||||
Follow: true,
|
||||
Timestamps: true,
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
c := &simple.Client{
|
||||
Request: simple.Request{
|
||||
Method: "GET",
|
||||
Path: testapi.Default.ResourcePath("pods", ns, "podName") + "/log",
|
||||
Query: url.Values{
|
||||
@@ -204,7 +207,7 @@ func TestPodGetLogs(t *testing.T) {
|
||||
"timestamps": []string{"true"},
|
||||
},
|
||||
},
|
||||
Response: Response{StatusCode: http.StatusOK},
|
||||
Response: simple.Response{StatusCode: http.StatusOK},
|
||||
}
|
||||
|
||||
body, err := c.Setup(t).Pods(ns).GetLogs("podName", opts).Stream()
|
||||
|
||||
Reference in New Issue
Block a user