當前位置: 首頁>>代碼示例>>Golang>>正文


Golang TestGroup.ResourcePath方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/api/testapi.TestGroup.ResourcePath方法的典型用法代碼示例。如果您正苦於以下問題:Golang TestGroup.ResourcePath方法的具體用法?Golang TestGroup.ResourcePath怎麽用?Golang TestGroup.ResourcePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/api/testapi.TestGroup的用法示例。


在下文中一共展示了TestGroup.ResourcePath方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: testGetJob

func testGetJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   group.ResourcePath(getJobsResourceName(), ns, "foo"),
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &extensions.Job{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: extensions.JobSpec{
					Template: api.PodTemplateSpec{},
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJob, err := getJobClient(t, c, ns, resourceGroup).Get("foo")
	defer c.Close()
	c.Validate(t, receivedJob, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:29,代碼來源:jobs_test.go

示例2: testHorizontalPodAutoscalerCreate

func testHorizontalPodAutoscalerCreate(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := extensions.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:      "abc",
			Namespace: ns,
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "POST",
			Path:   group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
			Query:  simple.BuildQueryValues(nil),
			Body:   &horizontalPodAutoscaler,
		},
		Response:      simple.Response{StatusCode: 200, Body: &horizontalPodAutoscaler},
		ResourceGroup: resourceGroup,
	}

	response, err := getHPAClient(t, c, ns, resourceGroup).Create(&horizontalPodAutoscaler)
	defer c.Close()
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, response, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:26,代碼來源:horizontalpodautoscaler_test.go

示例3: testListJob

func testListJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceAll
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   group.ResourcePath(getJobsResourceName(), ns, ""),
		},
		Response: simple.Response{StatusCode: 200,
			Body: &extensions.JobList{
				Items: []extensions.Job{
					{
						ObjectMeta: api.ObjectMeta{
							Name: "foo",
							Labels: map[string]string{
								"foo":  "bar",
								"name": "baz",
							},
						},
						Spec: extensions.JobSpec{
							Template: api.PodTemplateSpec{},
						},
					},
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJobList, err := getJobClient(t, c, ns, resourceGroup).List(api.ListOptions{})
	defer c.Close()
	c.Validate(t, receivedJobList, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:31,代碼來源:jobs_test.go

示例4: testHorizontalPodAutoscalerList

func testHorizontalPodAutoscalerList(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	horizontalPodAutoscalerList := &extensions.HorizontalPodAutoscalerList{
		Items: []extensions.HorizontalPodAutoscaler{
			{
				ObjectMeta: api.ObjectMeta{
					Name:      "foo",
					Namespace: ns,
				},
			},
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "GET",
			Path:   group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
			Query:  simple.BuildQueryValues(nil),
			Body:   nil,
		},
		Response:      simple.Response{StatusCode: 200, Body: horizontalPodAutoscalerList},
		ResourceGroup: resourceGroup,
	}
	response, err := getHPAClient(t, c, ns, resourceGroup).List(api.ListOptions{})
	defer c.Close()
	c.Validate(t, response, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:26,代碼來源:horizontalpodautoscaler_test.go

示例5: testHorizontalPodAutoscalerDelete

func testHorizontalPodAutoscalerDelete(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	c := &simple.Client{
		Request:       simple.Request{Method: "DELETE", Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
		Response:      simple.Response{StatusCode: 200},
		ResourceGroup: resourceGroup,
	}
	err := getHPAClient(t, c, ns, resourceGroup).Delete("foo", nil)
	defer c.Close()
	c.Validate(t, nil, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:11,代碼來源:horizontalpodautoscaler_test.go

示例6: testHorizontalPodAutoscalerUpdateStatus

func testHorizontalPodAutoscalerUpdateStatus(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	horizontalPodAutoscaler := &extensions.HorizontalPodAutoscaler{
		ObjectMeta: api.ObjectMeta{
			Name:            "abc",
			Namespace:       ns,
			ResourceVersion: "1",
		},
	}
	c := &simple.Client{
		Request:       simple.Request{Method: "PUT", Path: group.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc") + "/status", Query: simple.BuildQueryValues(nil)},
		Response:      simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler},
		ResourceGroup: resourceGroup,
	}
	response, err := getHPAClient(t, c, ns, resourceGroup).UpdateStatus(horizontalPodAutoscaler)
	defer c.Close()
	c.Validate(t, response, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:18,代碼來源:horizontalpodautoscaler_test.go

示例7: testCreateJob

func testCreateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	requestJob := &extensions.Job{
		ObjectMeta: api.ObjectMeta{
			Name:      "foo",
			Namespace: ns,
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "POST",
			Path:   group.ResourcePath(getJobsResourceName(), ns, ""),
			Body:   requestJob,
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &extensions.Job{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: extensions.JobSpec{
					Template: api.PodTemplateSpec{},
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJob, err := getJobClient(t, c, ns, resourceGroup).Create(requestJob)
	defer c.Close()
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	c.Validate(t, receivedJob, err)
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:39,代碼來源:jobs_test.go

示例8: testUpdateJobStatus

func testUpdateJobStatus(t *testing.T, group testapi.TestGroup, resourceGroup string) {
	ns := api.NamespaceDefault
	requestJob := &batch.Job{
		ObjectMeta: api.ObjectMeta{
			Name:            "foo",
			Namespace:       ns,
			ResourceVersion: "1",
		},
	}
	c := &simple.Client{
		Request: simple.Request{
			Method: "PUT",
			Path:   group.ResourcePath(getJobsResourceName(), ns, "foo") + "/status",
			Query:  simple.BuildQueryValues(nil),
		},
		Response: simple.Response{
			StatusCode: 200,
			Body: &batch.Job{
				ObjectMeta: api.ObjectMeta{
					Name: "foo",
					Labels: map[string]string{
						"foo":  "bar",
						"name": "baz",
					},
				},
				Spec: batch.JobSpec{
					Template: api.PodTemplateSpec{},
				},
				Status: batch.JobStatus{
					Active: 1,
				},
			},
		},
		ResourceGroup: resourceGroup,
	}
	receivedJob, err := getJobClient(t, c, ns, resourceGroup).UpdateStatus(requestJob)
	defer c.Close()
	c.Validate(t, receivedJob, err)
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:39,代碼來源:jobs_test.go


注:本文中的k8s/io/kubernetes/pkg/api/testapi.TestGroup.ResourcePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。