func (b *Binding) Delete(ctx *app.DeleteBindingContext) error { if !b.state.InstanceExists(ctx.InstanceId) { return ctx.Gone() } if !b.state.InstanceBindingExists(ctx.InstanceId, ctx.BindingId) { return ctx.Gone() } err := b.state.DeleteInstanceBinding(ctx.InstanceId, ctx.BindingId) if err != nil { return ctx.InternalServerError() } return ctx.OK(&app.CfbrokerDashboard{}) }
}) Context("when the binding id already exists", func() { BeforeEach(func() { state.InstanceExistsReturns(true) state.InstanceBindingExistsReturns(true) }) It("responds with 409", func() { Expect(goaContext.ResponseStatus()).To(Equal(409)) }) }) }) Describe("#Delete", func() { var bindingContext *app.DeleteBindingContext BeforeEach(func() { var err error bindingContext, err = app.NewDeleteBindingContext(goaContext) Expect(err).ToNot(HaveOccurred()) bindingContext.InstanceId = "instance-1" bindingContext.BindingId = "binding-1" }) JustBeforeEach(func() { bindingController = controllers.NewBinding(state) err := bindingController.Delete(bindingContext) Expect(err).ToNot(HaveOccurred()) })