Ejemplo n.º 1
0
func main() {
	service := goa.New("cfbroker")
	configuration, err := config.Load("./config.yaml")
	if err != nil {
		panic(err)
	}

	store, err := storage.NewLocalFile("/tmp/data")
	if err != nil {
		panic(err)
	}

	provisioningController := controllers.NewProvisioning(store)
	catalogController := commoncontrollers.NewCatalog(configuration.Catalog)

	app.MountCatalogController(service, catalogController)
	app.MountProvisioningController(service, provisioningController)

	swagger.MountController(service)
	service.ListenAndServe(":8080")
}
Ejemplo n.º 2
0
	"github.com/raphael/goa"
	"github.com/tscolari/cf-broker-api/common/controllers"
	"github.com/tscolari/memcached-broker/app"
	"github.com/tscolari/memcached-broker/config"
	"golang.org/x/net/context"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Catalog", func() {
	var catalogConfig app.CfbrokerCatalog
	var catalogController *controllers.Catalog

	BeforeEach(func() {
		config, err := config.Load("./assets/valid.config.yml")
		Expect(err).ToNot(HaveOccurred())
		catalogConfig = config.Catalog
		catalogController = controllers.NewCatalog(catalogConfig)
	})

	Describe("#Show", func() {
		var goaContext *goa.Context
		var catalogContext *app.ShowCatalogContext
		var responseWriter *httptest.ResponseRecorder

		BeforeEach(func() {
			gctx := context.Background()
			req := http.Request{}
			responseWriter = httptest.NewRecorder()
			params := url.Values{}
Ejemplo n.º 3
0
package config_test

import (
	"github.com/tscolari/memcached-broker/config"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Config", func() {

	Describe("#Load", func() {
		It("parses the file correctly", func() {
			config, err := config.Load("./assets/valid.config.yml")
			Expect(err).ToNot(HaveOccurred())

			Expect(len(config.Catalog.Services)).To(Equal(1))
		})

		Context("when the file doesn't exist", func() {
			It("fails", func() {
				_, err := config.Load("./assets/not-here.config.yml")
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("no such file or directory"))
			})
		})

		Context("when the is not a valid yaml", func() {
			It("fails", func() {
				_, err := config.Load("./assets/invalid.config.yml")
				Expect(err).To(HaveOccurred())