Пример #1
0
			var br brokerapi.BindingRequest
			br = brokerapi.BindingRequest{InstanceId: "myFakeInstance",
				BindingId: "fakeBindId",
				ServiceId: "mysql:latest",
				PlanId:    "100",
				AppId:     "myFakeApp",
			}
			pr := brokerapi.ProvisioningRequest{InstanceId: "myFakeInstance",
				ServiceId: "mysql:latest",
				PlanId:    "100",
				OrgId:     "myFakeOrg",
				SpaceId:   "myFakeSpace",
			}

			persister.AddServiceInstance("mysql:latest", 1234, 49153,
				"mysql://fakehost:1234", "myFakeInstance", "fakehost",
				"myFakeContainer", "mysql", pr, time.Now())

			_, creds, somestr, err := brokerservice.Bind(br)
			Expect(err).To(BeNil())
			fmt.Println(creds)
			Expect(creds["uri"]).To(Equal("mysql://fakehost:1234"))
			Expect(creds["host"]).To(Equal("fakeHost"))
			Expect(creds["port"]).To(Equal("1234"))
			Expect(creds["username"]).To(Equal("fakeUser"))
			Expect(creds["password"]).To(Equal("fakePassword"))
			Expect(creds["database"]).To(Equal("fakeDB"))
			Expect(somestr).To(Equal("unknown"))
		})

		It("should unbind a service", func() {
Пример #2
0
			var respmap map[string]interface{}
			json.Unmarshal(resp, &respmap)
			Expect(err).To(BeNil())
			Expect(respCode).Should(Equal(http.StatusCreated))
			Expect(respmap["dashboard_url"]).To(Equal("mysql://fakehost:1234"))
		})

		It("should fail to deprovision when the specific agent is not present", func() {
			brokerservice, serviceagent, ts, handler = testnet.NewBrokerServiceWithMultipleRequests(serviceagent, persister, []testnet.TestRequest{testnet.Deprovision_StopContainerRequest, testnet.Deprovision_RemoveContainerRequest})
			defer ts.Close()

			pr, b := newProvisioningRequest()

			persister.AddServiceInstance("mysql:latest", 1234, 49153,
				"mysql://fakehost:1234", "myFakeInstance", "fakehost", "fakecontainename", "fakeimagename",
				pr, time.Now())

			resp, respCode, err := SendHTTP("DELETE", BaseURL(opts)+"/v2/service_instances/myFakeInstance", b)
			Expect(err).To(BeNil())

			var respmap map[string]interface{}
			json.Unmarshal(resp, &respmap)
			Expect(err).To(BeNil())
			Expect(respCode).Should(Equal(http.StatusGone))
			Expect(respmap["description"]).To(ContainSubstring("can't find agent - assume its already gone"))
		})

		It("should deprovision a service", func() {
			brokerservice, serviceagent, ts, handler = testnet.NewBrokerServiceWithMultipleRequests(serviceagent, persister, []testnet.TestRequest{testnet.Deprovision_StopContainerRequest, testnet.Deprovision_RemoveContainerRequest})
			defer ts.Close()