예제 #1
0
						},
					},
				},
			}
		})

		It("translates the request into a task model, preserving attributes", func() {
			actualTask, err := serialization.TaskFromRequest(request)
			Expect(err).NotTo(HaveOccurred())

			Expect(actualTask).To(Equal(expectedTask))
		})

		Context("when the request contains a parseable completion_callback_url", func() {
			BeforeEach(func() {
				request.CompletionCallbackURL = "http://stager.service.discovery.thing/endpoint"
			})

			It("parses the URL", func() {
				actualTask, err := serialization.TaskFromRequest(request)
				Expect(err).NotTo(HaveOccurred())

				Expect(actualTask.CompletionCallbackURL).To(Equal(&url.URL{
					Scheme: "http",
					Host:   "stager.service.discovery.thing",
					Path:   "/endpoint",
				}))

			})
		})
					})
				})

				Context("when are not specified", func() {
					It("passes a nil slice to the BBS", func() {
						Expect(fakeClient.DesireTaskCallCount()).To(Equal(1))
						_, _, def := fakeClient.DesireTaskArgsForCall(0)
						Expect(def.EnvironmentVariables).To(BeNil())
						Expect(def.EgressRules).To(BeNil())
					})
				})
			})

			Context("when completion_callback_url is invalid", func() {
				BeforeEach(func() {
					validCreateRequest.CompletionCallbackURL = "ಠ_ಠ"
				})

				It("errors", func() {
					Expect(responseRecorder.Code).To(Equal(http.StatusBadRequest))
				})
			})
		})

		Context("when the BBS responds with an error", func() {
			BeforeEach(func() {
				fakeClient.DesireTaskReturns(errors.New("ka-boom"))
				handler.Create(responseRecorder, newTestRequest(validCreateRequest))
			})

			It("calls DesireTask on the BBS with the correct task", func() {