Beispiel #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")
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tscolari/cf-broker-api/common/repository"
	"github.com/tscolari/memcached-broker/storage"
)

var _ = Describe("LocalFile", func() {
	var localFile *storage.LocalFile
	var tempFileName string

	BeforeEach(func() {
		dir, err := ioutil.TempDir("/tmp/", "local-file")
		Expect(err).ToNot(HaveOccurred())

		tempFileName = fmt.Sprintf("%s/state.yml", dir)
		localFile, err = storage.NewLocalFile(tempFileName, 1)
		Expect(err).ToNot(HaveOccurred())
	})

	Describe("InstanceExists", func() {
		Context("when the instance exists", func() {
			BeforeEach(func() {
				localFile.AddInstance(repository.Instance{ID: "instance-id"})
			})

			It("returns true", func() {
				Expect(localFile.InstanceExists("instance-id")).To(BeTrue())
			})
		})

		Context("when the instance doesn't exist", func() {