Expect(err).NotTo(HaveOccurred())
		})

		Context("when the vhost exists", func() {
			It("returns ErrInstanceAlreadyExists error", func() {
				client.GetVhostReturns(&rabbithole.VhostInfo{}, nil)
				_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
				Expect(err).To(Equal(brokerapi.ErrInstanceAlreadyExists))
				Expect(client.PutVhostCallCount()).To(Equal(0))
			})
		})

		It("creates a vhost", func() {
			_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
			Expect(client.PutVhostCallCount()).To(Equal(1))
			vhost, _ := client.PutVhostArgsForCall(0)
			Expect(vhost).To(Equal("my-service-id"))
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when the vhost creation fails", func() {
			It("logs and returns an error", func() {
				client.PutVhostReturns(nil, fmt.Errorf("vhost-creation-failed"))
				_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
				Expect(err).To(MatchError("vhost-creation-failed"))
				Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("Failed to provision a service: my-service-id")))
			})

			Context("with error status code", func() {
				It("returns the status as error", func() {
					client.PutVhostReturns(&http.Response{StatusCode: http.StatusInternalServerError}, nil)