Example #1
0
import (
	"github.com/cloudfoundry-community/cf-subway/broker"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/pivotal-cf/brokerapi"
)

var _ = Describe("Service broker", func() {
	var subway *broker.Broker

	BeforeEach(func() {
		subway = broker.NewBroker()
		subway.Catalog = []brokerapi.Service{
			{
				Plans: []brokerapi.ServicePlan{{ID: "plan-uuid"}},
			},
		}
		subway.BackendBrokers = []*broker.BackendBroker{{URI: "TEST-SUCCESS"}}
	})

	Describe(".Provision", func() {
		Context("when the plan is recognized", func() {
			It("creates an instance if first backend ok", func() {
				subway.BackendBrokers = []*broker.BackendBroker{{URI: "TEST-SUCCESS"}}
				err := subway.Provision("some-id", brokerapi.ProvisionDetails{PlanID: "plan-uuid"})
				Ω(err).ToNot(HaveOccurred())
			})

			It("creates an instance if one backend ok", func() {
				subway.BackendBrokers = []*broker.BackendBroker{