예제 #1
0
func (p *Provisioning) Delete(ctx *app.DeleteProvisioningContext) error {
	if !p.state.InstanceExists(ctx.InstanceId) {
		return ctx.Gone()
	}

	err := p.state.DeleteInstance(ctx.InstanceId)
	if err != nil {
		return ctx.Gone()
	}

	return ctx.OK(&app.CfbrokerDashboard{})
}
		Context("when the instance doesn't exist", func() {
			BeforeEach(func() {
				state.InstanceReturns(nil, errors.New("Not here!"))
				err := provisioningController.Update(provisioningContext)
				Expect(err).ToNot(HaveOccurred())
			})

			It("responds with 404", func() {
				Expect(goaContext.ResponseStatus()).To(Equal(404))
			})
		})
	})

	Describe("#Delete", func() {
		var provisioningContext *app.DeleteProvisioningContext

		BeforeEach(func() {
			var err error
			provisioningContext, err = app.NewDeleteProvisioningContext(goaContext)
			Expect(err).ToNot(HaveOccurred())

			provisioningContext.InstanceId = "some-instance-id"
		})

		Context("when all goes ok", func() {
			BeforeEach(func() {
				state.InstanceExistsReturns(true)

				err := provisioningController.Delete(provisioningContext)
				Expect(err).ToNot(HaveOccurred())