Expect(goaContext.ResponseStatus()).To(Equal(201)) }) It("sends the correct message to the state", func() { recordedInstance := state.AddInstanceArgsForCall(0) Expect(recordedInstance.ID).To(Equal("some-instance-id")) Expect(recordedInstance.OrganizationID).To(Equal("org-1")) Expect(recordedInstance.SpaceID).To(Equal("space-1")) Expect(recordedInstance.ServiceID).To(Equal("service-1")) Expect(recordedInstance.PlanID).To(Equal("plan-1")) }) }) Context("when the instance id already exists", func() { BeforeEach(func() { state.InstanceExistsReturns(true) err := provisioningController.Create(provisioningContext) Expect(err).ToNot(HaveOccurred()) }) It("responds with 409", func() { Expect(goaContext.ResponseStatus()).To(Equal(409)) }) }) Context("when there's no capacity", func() { BeforeEach(func() { state.AddInstanceReturns(errors.New("Failed")) err := provisioningController.Create(provisioningContext) Expect(err).ToNot(HaveOccurred())