• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang net.RequestBodyMatcher函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/cli/testhelpers/net.RequestBodyMatcher函数的典型用法代码示例。如果您正苦于以下问题:Golang RequestBodyMatcher函数的具体用法?Golang RequestBodyMatcher怎么用?Golang RequestBodyMatcher使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了RequestBodyMatcher函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1:

	})

	setupTestServer := func(reqs ...testnet.TestRequest) {
		testServer, testHandler = testnet.NewServer(reqs)
		configRepo.SetApiEndpoint(testServer.URL)
	}

	Describe(".Create", func() {
		It("can create an app security group, given some attributes", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "POST",
				Path:   "/v2/security_groups",
				// FIXME: this matcher depend on the order of the key/value pairs in the map
				Matcher: testnet.RequestBodyMatcher(`{
					"name": "mygroup",
					"rules": [{"my-house": "my-rules"}],
					"space_guids": ["myspace"]
				}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})
			setupTestServer(req)

			err := repo.Create(
				"mygroup",
				[]map[string]string{{"my-house": "my-rules"}},
				[]string{"myspace"},
			)

			Expect(err).NotTo(HaveOccurred())
			Expect(testHandler).To(HaveAllRequestsCalled())
		})
开发者ID:herchu,项目名称:cli,代码行数:31,代码来源:security_group_test.go


示例2:

				}`,
				}})

			one := 1
			createdBuildpack, apiErr := repo.Create("name with space", &one, nil, nil)
			Expect(apiErr).To(HaveOccurred())
			Expect(createdBuildpack).To(Equal(models.Buildpack{}))
			Expect(apiErr.(errors.HttpError).ErrorCode()).To(Equal("290003"))
			Expect(apiErr.Error()).To(ContainSubstring("Buildpack is invalid"))
		})

		It("sets the position flag when creating a buildpack", func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:  "POST",
				Path:    "/v2/buildpacks",
				Matcher: testnet.RequestBodyMatcher(`{"name":"my-cool-buildpack","position":999}`),
				Response: testnet.TestResponse{
					Status: http.StatusCreated,
					Body: `{
					"metadata": {
						"guid": "my-cool-buildpack-guid"
					},
					"entity": {
						"name": "my-cool-buildpack",
						"position":999
					}
				}`},
			}))

			position := 999
			created, apiErr := repo.Create("my-cool-buildpack", &position, nil, nil)
开发者ID:Jack1996,项目名称:cli,代码行数:31,代码来源:buildpacks_test.go


示例3:

			_, apiErr := repo.FindByName("my-broker")

			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).To(HaveOccurred())
			Expect(apiErr.Error()).To(Equal("Service Broker my-broker not found"))
		})
	})

	Describe("Create", func() {
		It("creates the service broker with the given name, URL, username and password", func() {
			expectedReqBody := `{"name":"foobroker","broker_url":"http://example.com","auth_username":"foouser","auth_password":"password"}`

			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "POST",
				Path:     "/v2/service_brokers",
				Matcher:  testnet.RequestBodyMatcher(expectedReqBody),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})

			ts, handler, repo := createServiceBrokerRepo(req)
			defer ts.Close()

			apiErr := repo.Create("foobroker", "http://example.com", "foouser", "password")

			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).NotTo(HaveOccurred())
		})
	})

	Describe("Update", func() {
		It("updates the service broker with the given guid", func() {
开发者ID:herchu,项目名称:cli,代码行数:31,代码来源:service_brokers_test.go


示例4:

	`},
	})
}

var matchResourceRequest = testnet.TestRequest{
	Method: "PUT",
	Path:   "/v2/resource_match",
	Matcher: testnet.RequestBodyMatcher(testnet.RemoveWhiteSpaceFromBody(`[
	{
        "sha1": "2474735f5163ba7612ef641f438f4b5bee00127b",
        "size": 51
    },
    {
        "sha1": "f097424ce1fa66c6cb9f5e8a18c317376ec12e05",
        "size": 70
    },
    {
        "sha1": "d9c3a51de5c89c11331d3b90b972789f1a14699a",
        "size": 59
    },
    {
        "sha1": "345f999aef9070fb9a608e65cf221b7038156b6d",
        "size": 229
    }
]`)),
	Response: testnet.TestResponse{
		Status: http.StatusOK,
		Body:   matchedResources,
	},
}

var matchResourceRequestImbalanced = testnet.TestRequest{
开发者ID:yingkitw,项目名称:cli,代码行数:32,代码来源:application_bits_test.go


示例5:

			createdApp, apiErr := repo.Create(params)

			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).NotTo(HaveOccurred())

			app := models.Application{}
			app.Name = "my-cool-app"
			app.Guid = "my-cool-app-guid"
			Expect(createdApp).To(Equal(app))
		})

		It("omits fields that are not set", func() {
			request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "POST",
				Path:     "/v2/apps",
				Matcher:  testnet.RequestBodyMatcher(`{"name":"my-cool-app","instances":3,"memory":2048,"disk_quota":512,"space_guid":"some-space-guid"}`),
				Response: testnet.TestResponse{Status: http.StatusCreated, Body: createApplicationResponse},
			})

			ts, handler, repo := createAppRepo([]testnet.TestRequest{request})
			defer ts.Close()

			params := defaultAppParams()
			params.BuildpackUrl = nil
			params.StackGuid = nil
			params.Command = nil

			_, apiErr := repo.Create(params)
			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).NotTo(HaveOccurred())
		})
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:applications_test.go


示例6: createPasswordRepo

	testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
	testnet "github.com/cloudfoundry/cli/testhelpers/net"

	. "github.com/cloudfoundry/cli/cf/api/password"
	"github.com/cloudfoundry/cli/cf/trace/tracefakes"
	. "github.com/cloudfoundry/cli/testhelpers/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CloudControllerPasswordRepository", func() {
	It("updates your password", func() {
		req := apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "PUT",
			Path:     "/Users/my-user-guid/password",
			Matcher:  testnet.RequestBodyMatcher(`{"password":"new-password","oldPassword":"old-password"}`),
			Response: testnet.TestResponse{Status: http.StatusOK},
		})

		passwordUpdateServer, handler, repo := createPasswordRepo(req)
		defer passwordUpdateServer.Close()

		apiErr := repo.UpdatePassword("old-password", "new-password")
		Expect(handler).To(HaveAllRequestsCalled())
		Expect(apiErr).NotTo(HaveOccurred())
	})
})

func createPasswordRepo(req testnet.TestRequest) (passwordServer *httptest.Server, handler *testnet.TestHandler, repo Repository) {
	passwordServer, handler = testnet.NewServer([]testnet.TestRequest{req})
开发者ID:Reejoshi,项目名称:cli,代码行数:30,代码来源:password_test.go


示例7:

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()

		gateway := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
		repo = NewCloudControllerServiceBindingRepository(configRepo, gateway)
	})

	AfterEach(func() {
		testServer.Close()
	})

	Describe("Create", func() {
		var requestMatcher testnet.RequestMatcher
		Context("when the service binding can be created", func() {
			BeforeEach(func() {
				requestMatcher = testnet.RequestBodyMatcher(`{"app_guid":"my-app-guid","service_instance_guid":"my-service-instance-guid"}`)
			})

			JustBeforeEach(func() {
				setupTestServer(apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "POST",
					Path:     "/v2/service_bindings",
					Matcher:  requestMatcher,
					Response: testnet.TestResponse{Status: http.StatusCreated},
				}))
			})

			It("creates the service binding", func() {
				apiErr := repo.Create("my-service-instance-guid", "my-app-guid", nil)

				Expect(testHandler).To(HaveAllRequestsCalled())
开发者ID:yingkitw,项目名称:cli,代码行数:31,代码来源:service_bindings_test.go


示例8:

		testServer.Close()
	})

	setupTestServer := func(reqs ...testnet.TestRequest) {
		testServer, testHandler = testnet.NewServer(reqs)
		configRepo.SetAPIEndpoint(testServer.URL)
	}

	Describe(".Create", func() {
		It("can create an app security group, given some attributes", func() {
			req := apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "POST",
				Path:   "/v2/security_groups",
				// FIXME: this matcher depend on the order of the key/value pairs in the map
				Matcher: testnet.RequestBodyMatcher(`{
					"name": "mygroup",
					"rules": [{"my-house": "my-rules"}]
				}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})
			setupTestServer(req)

			err := repo.Create(
				"mygroup",
				[]map[string]interface{}{{"my-house": "my-rules"}},
			)

			Expect(err).NotTo(HaveOccurred())
			Expect(testHandler).To(HaveAllRequestsCalled())
		})
	})
开发者ID:jsloyer,项目名称:cli,代码行数:31,代码来源:security_groups_test.go


示例9:

	"github.com/cloudfoundry/cli/cf/net"
	testapi "github.com/cloudfoundry/cli/testhelpers/api"
	testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
	testnet "github.com/cloudfoundry/cli/testhelpers/net"

	. "github.com/cloudfoundry/cli/cf/api"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("UserProvidedServiceRepository", func() {
	It("creates a user provided service with a name and credentials", func() {
		req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "POST",
			Path:     "/v2/user_provided_service_instances",
			Matcher:  testnet.RequestBodyMatcher(`{"name":"my-custom-service","credentials":{"host":"example.com","password":"secret","user":"me"},"space_guid":"my-space-guid","syslog_drain_url":""}`),
			Response: testnet.TestResponse{Status: http.StatusCreated},
		})

		ts, handler, repo := createUserProvidedServiceInstanceRepo(req)
		defer ts.Close()

		apiErr := repo.Create("my-custom-service", "", map[string]string{
			"host":     "example.com",
			"user":     "me",
			"password": "secret",
		})
		Expect(handler).To(testnet.HaveAllRequestsCalled())
		Expect(apiErr).NotTo(HaveOccurred())
	})
开发者ID:GABONIA,项目名称:cli,代码行数:30,代码来源:user_provided_service_instances_test.go


示例10:

			Expect(quotas[0].Name).To(Equal("my-remote-quota"))
			Expect(quotas[0].MemoryLimit).To(Equal(uint64(1024)))
			Expect(quotas[0].RoutesLimit).To(Equal(123))
			Expect(quotas[0].ServicesLimit).To(Equal(321))

			Expect(quotas[1].Guid).To(Equal("my-quota-guid2"))
			Expect(quotas[2].Guid).To(Equal("my-quota-guid3"))
		})
	})

	Describe("AssignQuotaToOrg", func() {
		It("sets the quota for an organization", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "PUT",
				Path:     "/v2/organizations/my-org-guid",
				Matcher:  testnet.RequestBodyMatcher(`{"quota_definition_guid":"my-quota-guid"}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})

			setupTestServer(req)

			err := repo.AssignQuotaToOrg("my-org-guid", "my-quota-guid")
			Expect(testHandler).To(HaveAllRequestsCalled())
			Expect(err).NotTo(HaveOccurred())
		})
	})

	Describe("Create", func() {
		It("creates a new quota with the given name", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "POST",
开发者ID:herchu,项目名称:cli,代码行数:31,代码来源:quotas_test.go


示例11:

		})

		It("returns a 'not found' response when the space doesn't exist in the given org", func() {
			testSpacesDidNotFindByNameWithOrg("another-org-guid",
				func(repo SpaceRepository, spaceName string) (models.Space, error) {
					return repo.FindByNameInOrg(spaceName, "another-org-guid")
				},
			)
		})
	})

	It("creates spaces without a space-quota", func() {
		request := apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:  "POST",
			Path:    "/v2/spaces",
			Matcher: testnet.RequestBodyMatcher(`{"name":"space-name","organization_guid":"my-org-guid"}`),
			Response: testnet.TestResponse{Status: http.StatusCreated, Body: `
			{
				"metadata": {
					"guid": "space-guid"
				},
				"entity": {
					"name": "space-name"
				}
			}`},
		})

		ts, handler, repo := createSpacesRepo(request)
		defer ts.Close()

		space, apiErr := repo.Create("space-name", "my-org-guid", "")
开发者ID:jsloyer,项目名称:cli,代码行数:31,代码来源:spaces_test.go


示例12:

					}))

				_, err := repo.FindByUsername("my-user")
				Expect(uaaHandler).To(testnet.HaveAllRequestsCalled())
				Expect(err).To(BeAssignableToTypeOf(&errors.ModelNotFoundError{}))
			})
		})
	})

	Describe("creating users", func() {
		It("it creates users using the UAA /Users endpoint", func() {
			setupCCServer(
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "POST",
					Path:     "/v2/users",
					Matcher:  testnet.RequestBodyMatcher(`{"guid":"my-user-guid"}`),
					Response: testnet.TestResponse{Status: http.StatusCreated},
				}))

			setupUAAServer(
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method: "POST",
					Path:   "/Users",
					Matcher: testnet.RequestBodyMatcher(`{
					"userName":"my-user",
					"emails":[{"value":"my-user"}],
					"password":"my-password",
					"name":{
						"givenName":"my-user",
						"familyName":"my-user"}
					}`),
开发者ID:palakmathur,项目名称:cli,代码行数:31,代码来源:users_test.go


示例13:

				Expect(servicePlansFields[0].Active).To(BeTrue())
				Expect(servicePlansFields[1].Name).To(Equal("The small second"))
				Expect(servicePlansFields[1].Guid).To(Equal("the-small-second"))
				Expect(servicePlansFields[1].Free).To(BeTrue())
				Expect(servicePlansFields[1].Public).To(BeFalse())
				Expect(servicePlansFields[1].Active).To(BeFalse())
			})
		})
	})

	Describe(".Update", func() {
		BeforeEach(func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "PUT",
				Path:     "/v2/service_plans/my-service-plan-guid",
				Matcher:  testnet.RequestBodyMatcher(`{"name":"my-service-plan", "free":true, "description":"descriptive text", "public":true, "service_guid":"service-guid"}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			}))
		})

		It("Updates the service to public", func() {
			servicePlan := models.ServicePlanFields{
				Name:        "my-service-plan",
				Guid:        "my-service-plan-guid",
				Description: "descriptive text",
				Free:        true,
				Public:      false,
			}

			err := repo.Update(servicePlan, "service-guid", true)
			Expect(testHandler).To(HaveAllRequestsCalled())
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:service_plan_test.go


示例14:

					}}),
				createProgressEndpoint("running"),
				createProgressEndpoint("failed"),
			}...)

			Expect(apiErr).To(HaveOccurred())
		})

		Context("when there are no files to upload", func() {
			It("makes a request without a zipfile", func() {
				emptyDir := filepath.Join(fixturesDir, "empty-dir")
				err := testUploadApp(emptyDir,
					testnet.TestRequest{
						Method:  "PUT",
						Path:    "/v2/resource_match",
						Matcher: testnet.RequestBodyMatcher("[]"),
						Response: testnet.TestResponse{
							Status: http.StatusOK,
							Body:   "[]",
						},
					},
					testapi.NewCloudControllerTestRequest(testnet.TestRequest{
						Method: "PUT",
						Path:   "/v2/apps/my-cool-app-guid/bits",
						Matcher: func(request *http.Request) {
							err := request.ParseMultipartForm(maxMultipartResponseSizeInBytes)
							Expect(err).NotTo(HaveOccurred())
							defer request.MultipartForm.RemoveAll()

							Expect(len(request.MultipartForm.Value)).To(Equal(1), "Should have 1 value")
							valuePart, ok := request.MultipartForm.Value["resources"]
开发者ID:GABONIA,项目名称:cli,代码行数:31,代码来源:application_bits_test.go


示例15:

		})

		It("returns a 'not found' response when the space doesn't exist in the given org", func() {
			testSpacesDidNotFindByNameWithOrg("another-org-guid",
				func(repo SpaceRepository, spaceName string) (models.Space, error) {
					return repo.FindByNameInOrg(spaceName, "another-org-guid")
				},
			)
		})
	})

	It("creates spaces", func() {
		request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:  "POST",
			Path:    "/v2/spaces",
			Matcher: testnet.RequestBodyMatcher(`{"name":"space-name","organization_guid":"my-org-guid"}`),
			Response: testnet.TestResponse{Status: http.StatusCreated, Body: `
			{
				"metadata": {
					"guid": "space-guid"
				},
				"entity": {
					"name": "space-name"
				}
			}`},
		})

		ts, handler, repo := createSpacesRepo(request)
		defer ts.Close()

		space, apiErr := repo.Create("space-name", "my-org-guid")
开发者ID:jbinfo,项目名称:cli,代码行数:31,代码来源:spaces_test.go


示例16:

			testserver, handler, repo := createOrganizationRepo(requestHandler)
			defer testserver.Close()

			_, apiErr := repo.FindByName("org1")
			_, ok := apiErr.(*errors.ModelNotFoundError)
			Expect(ok).To(BeFalse())
			Expect(handler).To(HaveAllRequestsCalled())
		})
	})

	Describe("creating organizations", func() {
		It("creates the org", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "POST",
				Path:     "/v2/organizations",
				Matcher:  testnet.RequestBodyMatcher(`{"name":"my-org"}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})

			testserver, handler, repo := createOrganizationRepo(req)
			defer testserver.Close()

			apiErr := repo.Create("my-org")
			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).NotTo(HaveOccurred())
		})
	})

	Describe("renaming orgs", func() {
		It("renames the org with the given guid", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
开发者ID:BlueSpice,项目名称:cli,代码行数:31,代码来源:organizations_test.go


示例17:

			err := repo.UnassignQuotaFromSpace("my-space-guid", "my-quota-guid")
			Expect(err).NotTo(HaveOccurred())
			Expect(testHandler).To(HaveAllRequestsCalled())
		})
	})

	Describe("Create", func() {
		It("creates a new quota with the given name", func() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "POST",
				Path:   "/v2/space_quota_definitions",
				Matcher: testnet.RequestBodyMatcher(`{
					"name": "not-so-strict",
					"non_basic_services_allowed": false,
					"total_services": 1,
					"total_routes": 12,
					"memory_limit": 123,
					"organization_guid": "my-org-guid"
				}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			})
			setupTestServer(req)

			quota := models.SpaceQuota{
				Name:          "not-so-strict",
				ServicesLimit: 1,
				RoutesLimit:   12,
				MemoryLimit:   123,
				OrgGuid:       "my-org-guid",
			}
			err := repo.Create(quota)
开发者ID:Jack1996,项目名称:cli,代码行数:31,代码来源:space_quotas_test.go


示例18:

			secondOffering := offerings[1]
			Expect(secondOffering.Label).To(Equal("Offering 1"))
			Expect(secondOffering.Version).To(Equal("1.0"))
			Expect(secondOffering.Description).To(Equal("Offering 1 description"))
			Expect(secondOffering.Provider).To(Equal("Offering 1 provider"))
			Expect(secondOffering.Guid).To(Equal("offering-1-guid"))
			Expect(len(secondOffering.Plans)).To(Equal(2))
		})
	})

	Describe("creating a service instance", func() {
		It("makes the right request", func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "POST",
				Path:     "/v2/service_instances",
				Matcher:  testnet.RequestBodyMatcher(`{"name":"instance-name","service_plan_guid":"plan-guid","space_guid":"my-space-guid","async":true}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			}))

			err := repo.CreateServiceInstance("instance-name", "plan-guid")
			Expect(testHandler).To(testnet.HaveAllRequestsCalled())
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when the name is taken but an identical service exists", func() {
			BeforeEach(func() {
				setupTestServer(
					testapi.NewCloudControllerTestRequest(testnet.TestRequest{
						Method:  "POST",
						Path:    "/v2/service_instances",
						Matcher: testnet.RequestBodyMatcher(`{"name":"my-service","service_plan_guid":"plan-guid","space_guid":"my-space-guid","async":true}`),
开发者ID:GABONIA,项目名称:cli,代码行数:31,代码来源:services_test.go


示例19:

	}

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetAccessToken("BEARER my_access_token")

		gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
		repo = NewCloudControllerServiceKeyRepository(configRepo, gateway)
	})

	Describe("CreateServiceKey", func() {
		It("makes the right request", func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:   "POST",
				Path:     "/v2/service_keys",
				Matcher:  testnet.RequestBodyMatcher(`{"service_instance_guid": "fake-instance-guid", "name": "fake-key-name"}`),
				Response: testnet.TestResponse{Status: http.StatusCreated},
			}))

			err := repo.CreateServiceKey("fake-instance-guid", "fake-key-name", nil)
			Expect(testHandler).To(HaveAllRequestsCalled())
			Expect(err).NotTo(HaveOccurred())
		})

		It("returns a ModelAlreadyExistsError if the service key exists", func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method:  "POST",
				Path:    "/v2/service_keys",
				Matcher: testnet.RequestBodyMatcher(`{"service_instance_guid":"fake-instance-guid","name":"exist-service-key"}`),
				Response: testnet.TestResponse{
					Status: http.StatusBadRequest,
开发者ID:tools-alexuser01,项目名称:cli,代码行数:31,代码来源:service_keys_test.go


示例20:

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
		repo = NewCloudControllerCopyApplicationSourceRepository(configRepo, gateway)
	})

	AfterEach(func() {
		testServer.Close()
	})

	Describe(".CopyApplication", func() {
		BeforeEach(func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "POST",
				Path:   "/v2/apps/target-app-guid/copy_bits",
				Matcher: testnet.RequestBodyMatcher(`{
					"source_app_guid": "source-app-guid"
				}`),
				Response: testnet.TestResponse{
					Status: http.StatusCreated,
				},
			}))
		})

		It("should return a CopyApplicationModel", func() {
			err := repo.CopyApplication("source-app-guid", "target-app-guid")
			Expect(err).ToNot(HaveOccurred())
		})
	})
})
开发者ID:vframbach,项目名称:cli,代码行数:30,代码来源:copy_application_source_test.go



注:本文中的github.com/cloudfoundry/cli/testhelpers/net.RequestBodyMatcher函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang requirements.FakeReqFactory类代码示例发布时间:2022-05-23
下一篇:
Golang net.NewServer函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap