Expect(decodedTask).To(Equal(&task)) }) Context("with an invalid payload", func() { It("returns the error", func() { decodedTask := &models.Task{} err := models.FromJSON([]byte("aliens lol"), decodedTask) Expect(err).To(HaveOccurred()) }) }) }) Describe("DesireTaskRequest", func() { Describe("Validate", func() { var request models.DesireTaskRequest BeforeEach(func() { request = models.DesireTaskRequest{ TaskGuid: "t-guid", Domain: "domain", TaskDefinition: model_helpers.NewValidTaskDefinition(), } }) Context("when valid", func() { It("returns nil", func() { Expect(request.Validate()).To(BeNil()) }) })
runner.Stop() }) Context("when started", func() { BeforeEach(func() { runner.Start( "-lifecycle", "buildpack/linux:lifecycle.zip", "-lifecycle", "docker:docker/lifecycle.tgz", ) Eventually(runner.Session()).Should(gbytes.Say("Listening for staging requests!")) }) Describe("when a buildpack staging request is received", func() { It("desires a staging task via the API", func() { fakeBBS.RouteToHandler("POST", "/v1/tasks/desire", func(w http.ResponseWriter, req *http.Request) { var desireTaskRequest models.DesireTaskRequest data, err := ioutil.ReadAll(req.Body) Expect(err).NotTo(HaveOccurred()) err = desireTaskRequest.Unmarshal(data) Expect(err).NotTo(HaveOccurred()) Expect(desireTaskRequest.TaskDefinition.MemoryMb).To(Equal(int32(1024))) Expect(desireTaskRequest.TaskDefinition.DiskMb).To(Equal(int32(128))) Expect(desireTaskRequest.TaskDefinition.CompletionCallbackUrl).To(Equal(callbackURL)) }) req, err := requestGenerator.CreateRequest(stager.StageRoute, rata.Params{"staging_guid": "my-task-guid"}, strings.NewReader(`{ "app_id":"my-app-guid", "file_descriptors":3, "memory_mb" : 1024,