Example #1
0
func main() {
	ipAddress := os.Getenv("REDIS_IP")

	serviceBroker := broker.New(broker.DatabaseIDs{}, ipAddress)
	logger := lager.NewLogger("redis-service-broker")
	credentials := brokerapi.BrokerCredentials{
		Username: "******",
		Password: "******",
	}

	brokerAPI := brokerapi.New(&serviceBroker, logger, credentials)
	fmt.Println("Listening on port " + os.Getenv("PORT") + " with IP " + ipAddress)
	http.Handle("/", brokerAPI)
	if err := http.ListenAndServe(":"+os.Getenv("PORT"), nil); err != nil {
		log.Fatal("ListenAndServe:", err)
	}
}
	"github.com/benchapman/redis-broker/broker"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-cf/brokerapi"

	"testing"
)

var _ = Describe(".RedisService", func() {
	var (
		redisBroker broker.RedisService
	)

	JustBeforeEach(func() {
		redisBroker = broker.New(broker.DatabaseIDs{}, "0.0.0.0")
	})

	Describe(".Services", func() {
		It("works", func() {
			Expect(redisBroker.Services()[0].Name).To(Equal("Shared Redis"))
		})
	})

	Describe(".Provision", func() {
		Context("if there are databases available", func() {
			It("should return a nil error", func() {
				_, err := redisBroker.Provision(
					"Pikachu",
					brokerapi.ProvisionDetails{},
					false,