本文整理汇总了Golang中github.com/ttysteale/kubernetes-api/client/unversioned/testclient/simple.BuildQueryValues函数的典型用法代码示例。如果您正苦于以下问题:Golang BuildQueryValues函数的具体用法?Golang BuildQueryValues怎么用?Golang BuildQueryValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BuildQueryValues函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestServiceProxyGet
func TestServiceProxyGet(t *testing.T) {
body := "OK"
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("services", ns, "service-1") + "/proxy/foo",
Query: simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}),
},
Response: simple.Response{StatusCode: 200, RawBody: &body},
}
response, err := c.Setup(t).Services(ns).ProxyGet("", "service-1", "", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
defer c.Close()
c.ValidateRaw(t, response, err)
// With scheme and port specified
c = &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("services", ns, "https:service-1:my-port") + "/proxy/foo",
Query: simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}),
},
Response: simple.Response{StatusCode: 200, RawBody: &body},
}
response, err = c.Setup(t).Services(ns).ProxyGet("https", "service-1", "my-port", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
defer c.Close()
c.ValidateRaw(t, response, err)
}
示例2: 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: &batch.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: batch.JobSpec{
Template: api.PodTemplateSpec{},
},
},
},
ResourceGroup: resourceGroup,
}
receivedJob, err := getJobClient(t, c, ns, resourceGroup).Get("foo")
defer c.Close()
c.Validate(t, receivedJob, err)
}
示例3: TestHorizontalPodAutoscalerList
func TestHorizontalPodAutoscalerList(t *testing.T) {
ns := api.NamespaceDefault
horizontalPodAutoscalerList := &autoscaling.HorizontalPodAutoscalerList{
Items: []autoscaling.HorizontalPodAutoscaler{
{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: ns,
},
},
},
}
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
Query: simple.BuildQueryValues(nil),
Body: nil,
},
Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscalerList},
ResourceGroup: autoscaling.GroupName,
}
response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).List(api.ListOptions{})
defer c.Close()
c.Validate(t, response, err)
}
示例4: TestListPodsLabels
func TestListPodsLabels(t *testing.T) {
ns := api.NamespaceDefault
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("pods", ns, ""),
Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Response: simple.Response{
StatusCode: http.StatusOK,
Body: &api.PodList{
Items: []api.Pod{
{
Status: api.PodStatus{
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
},
},
},
},
}
c.Setup(t)
defer c.Close()
c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels
selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
options := api.ListOptions{LabelSelector: selector}
receivedPodList, err := c.Pods(ns).List(options)
c.Validate(t, receivedPodList, err)
}
示例5: TestHorizontalPodAutoscalerCreate
func TestHorizontalPodAutoscalerCreate(t *testing.T) {
ns := api.NamespaceDefault
horizontalPodAutoscaler := autoscaling.HorizontalPodAutoscaler{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: ns,
},
}
c := &simple.Client{
Request: simple.Request{
Method: "POST",
Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""),
Query: simple.BuildQueryValues(nil),
Body: &horizontalPodAutoscaler,
},
Response: simple.Response{StatusCode: 200, Body: &horizontalPodAutoscaler},
ResourceGroup: autoscaling.GroupName,
}
response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Create(&horizontalPodAutoscaler)
defer c.Close()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
c.Validate(t, response, err)
}
示例6: TestListServices
func TestListServices(t *testing.T) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("services", ns, ""),
Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200,
Body: &api.ServiceList{
Items: []api.Service{
{
ObjectMeta: api.ObjectMeta{
Name: "name",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"one": "two",
},
},
},
},
},
},
}
receivedServiceList, err := c.Setup(t).Services(ns).List(api.ListOptions{})
defer c.Close()
t.Logf("received services: %v %#v", err, receivedServiceList)
c.Validate(t, receivedServiceList, err)
}
示例7: TestGetService
func TestGetService(t *testing.T) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("services", ns, "1"),
Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
}
response, err := c.Setup(t).Services(ns).Get("1")
defer c.Close()
c.Validate(t, response, err)
}
示例8: testDeleteJob
func testDeleteJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{
Method: "DELETE",
Path: group.ResourcePath(getJobsResourceName(), ns, "foo"),
Query: simple.BuildQueryValues(nil),
},
Response: simple.Response{StatusCode: 200},
ResourceGroup: resourceGroup,
}
err := getJobClient(t, c, ns, resourceGroup).Delete("foo", nil)
defer c.Close()
c.Validate(t, nil, err)
}
示例9: TestUpdateServiceStatus
func TestUpdateServiceStatus(t *testing.T) {
ns := api.NamespaceDefault
lbStatus := api.LoadBalancerStatus{
Ingress: []api.LoadBalancerIngress{
{IP: "127.0.0.1"},
},
}
requestService := &api.Service{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: ns,
ResourceVersion: "1",
},
Status: api.ServiceStatus{
LoadBalancer: lbStatus,
},
}
c := &simple.Client{
Request: simple.Request{
Method: "PUT",
Path: testapi.Default.ResourcePath("services", ns, "foo") + "/status",
Query: simple.BuildQueryValues(nil),
},
Response: simple.Response{
StatusCode: 200,
Body: &api.Service{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: api.ServiceSpec{},
Status: api.ServiceStatus{
LoadBalancer: lbStatus,
},
},
},
}
receivedService, err := c.Setup(t).Services(ns).UpdateStatus(requestService)
defer c.Close()
c.Validate(t, receivedService, err)
}
示例10: testCreateJob
func testCreateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) {
ns := api.NamespaceDefault
requestJob := &batch.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: &batch.Job{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: batch.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)
}
示例11: TestListServicesLabels
func TestListServicesLabels(t *testing.T) {
ns := api.NamespaceDefault
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
c := &simple.Client{
Request: simple.Request{
Method: "GET",
Path: testapi.Default.ResourcePath("services", ns, ""),
Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Response: simple.Response{StatusCode: 200,
Body: &api.ServiceList{
Items: []api.Service{
{
ObjectMeta: api.ObjectMeta{
Name: "name",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"one": "two",
},
},
},
},
},
},
}
c.Setup(t)
defer c.Close()
c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels
selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector()
options := api.ListOptions{LabelSelector: selector}
receivedServiceList, err := c.Services(ns).List(options)
c.Validate(t, receivedServiceList, err)
}
示例12: TestUpdateReplicaSet
func TestUpdateReplicaSet(t *testing.T) {
ns := api.NamespaceDefault
requestRS := &extensions.ReplicaSet{
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
}
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{
StatusCode: 200,
Body: &extensions.ReplicaSet{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
Spec: extensions.ReplicaSetSpec{
Replicas: 2,
Template: api.PodTemplateSpec{},
},
},
},
}
receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).Update(requestRS)
c.Validate(t, receivedRS, err)
}
示例13: TestHorizontalPodAutoscalerDelete
func TestHorizontalPodAutoscalerDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &simple.Client{
Request: simple.Request{Method: "DELETE", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200},
ResourceGroup: autoscaling.GroupName,
}
err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Delete("foo", nil)
defer c.Close()
c.Validate(t, nil, err)
}
示例14: TestHorizontalPodAutoscalerUpdateStatus
func TestHorizontalPodAutoscalerUpdateStatus(t *testing.T) {
ns := api.NamespaceDefault
horizontalPodAutoscaler := &autoscaling.HorizontalPodAutoscaler{
ObjectMeta: api.ObjectMeta{
Name: "abc",
Namespace: ns,
ResourceVersion: "1",
},
}
c := &simple.Client{
Request: simple.Request{Method: "PUT", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc") + "/status", Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler},
ResourceGroup: autoscaling.GroupName,
}
response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).UpdateStatus(horizontalPodAutoscaler)
defer c.Close()
c.Validate(t, response, err)
}
示例15: TestDeleteThirdPartyResource
func TestDeleteThirdPartyResource(t *testing.T) {
c := &simple.Client{
Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)},
Response: simple.Response{StatusCode: 200},
}
err := c.Setup(t).Extensions().ThirdPartyResources().Delete("foo")
defer c.Close()
c.Validate(t, nil, err)
}