It("checks that the agent configuration includes a blobstore section", func() { jsonReader := strings.NewReader(`{"apiserver":"localhost:8080", "agent":{"mbus":"localhost"}}`) _, err := config.New(jsonReader, request) Expect(err).To(MatchError(`Agent config invalid {map[] localhost []}`)) }) It("checks that the agent configuration includes a blobstore provider section", func() { jsonReader := strings.NewReader(`{"apiserver":"localhost:8080", "agent":{"mbus":"localhost","blobstore":{"some": "options"}}}`) _, err := config.New(jsonReader, request) Expect(err).To(MatchError(`Agent config invalid {map[some:options] localhost []}`)) }) Context("with a request to create a VM", func() { It("sets a default for max_create_vm_attmpts if not provided", func() { jsonReader := strings.NewReader(`{"apiserver":"localhost:8080", "agent":{"blobstore": {"provider": "local", "some": "options"}, "mbus":"localhost"}}`) request.Method = bosh.CREATE_VM c, err := config.New(jsonReader, request) Expect(err).ToNot(HaveOccurred()) Expect(c.MaxCreateVMAttempt).To(Equal(config.DefaultMaxCreateVMAttempts())) }) }) Context("without a request to create a VM", func() { It("sets max_create_vm_attmpts to zero if not provided", func() { jsonReader := strings.NewReader(`{"apiserver":"localhost:8080", "agent":{"blobstore": {"provider": "local", "some": "options"}, "mbus":"localhost"}}`) c, err := config.New(jsonReader, request) Expect(err).ToNot(HaveOccurred()) Expect(c.MaxCreateVMAttempt).To(Equal(0)) }) }) })