示例#1
0
func TestUpdateDaemon(t *testing.T) {
	ns := api.NamespaceDefault
	requestController := &expapi.Daemon{
		ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
	}
	c := &testClient{
		Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
		Response: Response{
			StatusCode: 200,
			Body: &expapi.Daemon{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: expapi.DaemonSpec{
					Template: &api.PodTemplateSpec{},
				},
			},
		},
	}
	receivedController, err := c.Setup().Experimental().Daemons(ns).Update(requestController)
	c.Validate(t, receivedController, err)
}
示例#2
0
func TestListDaemons(t *testing.T) {
	ns := api.NamespaceAll
	c := &testClient{
		Request: testRequest{
			Method: "GET",
			Path:   testapi.ResourcePath(getDCResourceName(), ns, ""),
		},
		Response: Response{StatusCode: 200,
			Body: &expapi.DaemonList{
				Items: []expapi.Daemon{
					{
						ObjectMeta: api.ObjectMeta{
							Name: "foo",
							Labels: map[string]string{
								"foo":  "bar",
								"name": "baz",
							},
						},
						Spec: expapi.DaemonSpec{
							Template: &api.PodTemplateSpec{},
						},
					},
				},
			},
		},
	}
	receivedControllerList, err := c.Setup().Experimental().Daemons(ns).List(labels.Everything())
	c.Validate(t, receivedControllerList, err)

}
示例#3
0
func TestDeleteDaemon(t *testing.T) {
	ns := api.NamespaceDefault
	c := &testClient{
		Request:  testRequest{Method: "DELETE", Path: testapi.ResourcePath(getDCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
		Response: Response{StatusCode: 200},
	}
	err := c.Setup().Experimental().Daemons(ns).Delete("foo")
	c.Validate(t, nil, err)
}
func TestHorizontalPodAutoscalerDelete(t *testing.T) {
	ns := api.NamespaceDefault
	c := &testClient{
		Request:  testRequest{Method: "DELETE", Path: testapi.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: buildQueryValues(nil)},
		Response: Response{StatusCode: 200},
	}
	err := c.Setup().HorizontalPodAutoscalers(ns).Delete("foo", nil)
	c.Validate(t, nil, err)
}
func TestHorizontalPodAutoscalerUpdate(t *testing.T) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := &expapi.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:            "abc",
			Namespace:       ns,
			ResourceVersion: "1",
		},
	}
	c := &testClient{
		Request:  testRequest{Method: "PUT", Path: testapi.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc"), Query: buildQueryValues(nil)},
		Response: Response{StatusCode: 200, Body: horizontalPodAutoscaler},
	}
	response, err := c.Setup().HorizontalPodAutoscalers(ns).Update(horizontalPodAutoscaler)
	c.Validate(t, response, err)
}
func TestDeploymentUpdate(t *testing.T) {
	ns := api.NamespaceDefault
	deployment := &expapi.Deployment{
		ObjectMeta: api.ObjectMeta{
			Name:            "abc",
			Namespace:       ns,
			ResourceVersion: "1",
		},
	}
	c := &testClient{
		Request: testRequest{
			Method: "PUT",
			Path:   testapi.ResourcePath(getDeploymentsResoureName(), ns, "abc"),
			Query:  buildQueryValues(nil),
		},
		Response: Response{StatusCode: 200, Body: deployment},
	}
	response, err := c.Setup().Deployments(ns).Update(deployment)
	c.Validate(t, response, err)
}
func TestDeploymentList(t *testing.T) {
	ns := api.NamespaceDefault
	deploymentList := &expapi.DeploymentList{
		Items: []expapi.Deployment{
			{
				ObjectMeta: api.ObjectMeta{
					Name:      "foo",
					Namespace: ns,
				},
			},
		},
	}
	c := &testClient{
		Request: testRequest{
			Method: "GET",
			Path:   testapi.ResourcePath(getDeploymentsResoureName(), ns, ""),
			Query:  buildQueryValues(nil),
			Body:   nil,
		},
		Response: Response{StatusCode: 200, Body: deploymentList},
	}
	response, err := c.Setup().Deployments(ns).List(labels.Everything(), fields.Everything())
	c.Validate(t, response, err)
}
func TestDeploymentCreate(t *testing.T) {
	ns := api.NamespaceDefault
	deployment := expapi.Deployment{
		ObjectMeta: api.ObjectMeta{
			Name:      "abc",
			Namespace: ns,
		},
	}
	c := &testClient{
		Request: testRequest{
			Method: "POST",
			Path:   testapi.ResourcePath(getDeploymentsResoureName(), ns, ""),
			Query:  buildQueryValues(nil),
			Body:   &deployment,
		},
		Response: Response{StatusCode: 200, Body: &deployment},
	}

	response, err := c.Setup().Deployments(ns).Create(&deployment)
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, response, err)
}
func TestHorizontalPodAutoscalerCreate(t *testing.T) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := expapi.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:      "abc",
			Namespace: ns,
		},
	}
	c := &testClient{
		Request: testRequest{
			Method: "POST",
			Path:   testapi.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
			Query:  buildQueryValues(nil),
			Body:   &horizontalPodAutoscaler,
		},
		Response: Response{StatusCode: 200, Body: &horizontalPodAutoscaler},
	}

	response, err := c.Setup().HorizontalPodAutoscalers(ns).Create(&horizontalPodAutoscaler)
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, response, err)
}