serviceInstanceReq := new(requirementsfakes.FakeServiceInstanceRequirement) serviceInstanceReq.GetServiceInstanceReturns(serviceInstance) requirementsFactory.NewServiceInstanceRequirementReturns(serviceInstanceReq) }) It("binds a service instance to an app", func() { callBindService([]string{"my-app", "my-service"}) Expect(ui.Outputs()).To(ContainSubstrings( []string{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"}, []string{"OK"}, []string{"TIP", "my-app"}, )) Expect(serviceBindingRepo.CreateCallCount()).To(Equal(1)) serviceInstanceGUID, applicationGUID, _ := serviceBindingRepo.CreateArgsForCall(0) Expect(serviceInstanceGUID).To(Equal("my-service-guid")) Expect(applicationGUID).To(Equal("my-app-guid")) }) It("warns the user when the service instance is already bound to the given app", func() { serviceBindingRepo.CreateReturns(errors.NewHTTPError(http.StatusBadRequest, errors.ServiceBindingAppServiceTaken, "")) callBindService([]string{"my-app", "my-service"}) Expect(ui.Outputs()).To(ContainSubstrings( []string{"Binding service"}, []string{"OK"}, []string{"my-app", "is already bound", "my-service"}, )) })