本文整理汇总了Golang中github.com/cloudfoundry/cli/testhelpers/net.HaveAllRequestsCalled函数的典型用法代码示例。如果您正苦于以下问题:Golang HaveAllRequestsCalled函数的具体用法?Golang HaveAllRequestsCalled怎么用?Golang HaveAllRequestsCalled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HaveAllRequestsCalled函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testSpacesDidNotFindByNameWithOrg
func testSpacesDidNotFindByNameWithOrg(orgGuid string, findByName func(SpaceRepository, string) (models.Space, error)) {
request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: fmt.Sprintf("/v2/organizations/%s/spaces?q=name%%3Aspace1&inline-relations-depth=1", orgGuid),
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: ` { "resources": [ ] }`,
},
})
ts, handler, repo := createSpacesRepo(request)
defer ts.Close()
_, apiErr := findByName(repo, "Space1")
Expect(handler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr.(*errors.ModelNotFoundError)).NotTo(BeNil())
}
示例2:
Describe("Create", func() {
Context("when the service binding can be created", func() {
BeforeEach(func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "POST",
Path: "/v2/service_bindings",
Matcher: testnet.RequestBodyMatcher(`{"app_guid":"my-app-guid","service_instance_guid":"my-service-instance-guid","async":true}`),
Response: testnet.TestResponse{Status: http.StatusCreated},
}))
})
It("TestCreateServiceBinding", func() {
apiErr := repo.Create("my-service-instance-guid", "my-app-guid")
Expect(testHandler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
})
})
Context("when an error occurs", func() {
BeforeEach(func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "POST",
Path: "/v2/service_bindings",
Matcher: testnet.RequestBodyMatcher(`{"app_guid":"my-app-guid","service_instance_guid":"my-service-instance-guid","async":true}`),
Response: testnet.TestResponse{
Status: http.StatusBadRequest,
Body: `{"code":90003,"description":"The app space binding to service is taken: 7b959018-110a-4913-ac0a-d663e613cdea 346bf237-7eef-41a7-b892-68fb08068f09"}`,
},
}))
示例3:
It("fails to upload a buildpack with an invalid directory", func() {
apiErr := repo.UploadBuildpack(buildpack, "/foo/bar")
Expect(apiErr).NotTo(BeNil())
Expect(apiErr.Error()).To(ContainSubstring("Error opening buildpack file"))
})
It("uploads a valid buildpack directory", func() {
buildpackPath := filepath.Join(buildpacksDir, "example-buildpack")
os.Chmod(filepath.Join(buildpackPath, "bin/compile"), 0755)
os.Chmod(filepath.Join(buildpackPath, "bin/detect"), 0755)
err := os.Chmod(filepath.Join(buildpackPath, "bin/release"), 0755)
Expect(err).NotTo(HaveOccurred())
apiErr := repo.UploadBuildpack(buildpack, buildpackPath)
Expect(testServerHandler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
})
It("uploads a valid zipped buildpack", func() {
buildpackPath := filepath.Join(buildpacksDir, "example-buildpack.zip")
apiErr := repo.UploadBuildpack(buildpack, buildpackPath)
Expect(testServerHandler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
})
Describe("when the buildpack is wrapped in an extra top-level directory", func() {
It("uploads a zip file containing only the actual buildpack", func() {
buildpackPath := filepath.Join(buildpacksDir, "example-buildpack-in-dir.zip")
示例4: testSpacesFindByNameWithOrg
func testSpacesFindByNameWithOrg(orgGuid string, findByName func(SpaceRepository, string) (models.Space, error)) {
findSpaceByNameResponse := testnet.TestResponse{
Status: http.StatusOK,
Body: `
{
"resources": [
{
"metadata": {
"guid": "space1-guid"
},
"entity": {
"name": "Space1",
"organization_guid": "org1-guid",
"organization": {
"metadata": {
"guid": "org1-guid"
},
"entity": {
"name": "Org1"
}
},
"apps": [
{
"metadata": {
"guid": "app1-guid"
},
"entity": {
"name": "app1"
}
},
{
"metadata": {
"guid": "app2-guid"
},
"entity": {
"name": "app2"
}
}
],
"domains": [
{
"metadata": {
"guid": "domain1-guid"
},
"entity": {
"name": "domain1"
}
}
],
"service_instances": [
{
"metadata": {
"guid": "service1-guid"
},
"entity": {
"name": "service1"
}
}
]
}
}
]
}`}
request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: fmt.Sprintf("/v2/organizations/%s/spaces?q=name%%3Aspace1&inline-relations-depth=1", orgGuid),
Response: findSpaceByNameResponse,
})
ts, handler, repo := createSpacesRepo(request)
defer ts.Close()
space, apiErr := findByName(repo, "Space1")
Expect(handler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
Expect(space.Name).To(Equal("Space1"))
Expect(space.Guid).To(Equal("space1-guid"))
Expect(space.Organization.Guid).To(Equal("org1-guid"))
Expect(len(space.Applications)).To(Equal(2))
Expect(space.Applications[0].Guid).To(Equal("app1-guid"))
Expect(space.Applications[1].Guid).To(Equal("app2-guid"))
Expect(len(space.Domains)).To(Equal(1))
Expect(space.Domains[0].Guid).To(Equal("domain1-guid"))
Expect(len(space.ServiceInstances)).To(Equal(1))
Expect(space.ServiceInstances[0].Guid).To(Equal("service1-guid"))
Expect(apiErr).NotTo(HaveOccurred())
return
}