var responseWriter http.ResponseWriter
		var outgoingResponse *httptest.ResponseRecorder
		var uploader fake_ccclient.FakeUploader
		var poller fake_ccclient.FakePoller
		var logger lager.Logger

		BeforeEach(func() {
			outgoingResponse = httptest.NewRecorder()
			responseWriter = outgoingResponse
			uploader = fake_ccclient.FakeUploader{}
			poller = fake_ccclient.FakePoller{}
		})

		JustBeforeEach(func() {
			logger = lager.NewLogger("fake-logger")
			dropletUploadHandler := upload_droplet.New(&uploader, &poller, logger)

			dropletUploadHandler.ServeHTTP(responseWriter, incomingRequest)
		})

		Context("When the request does not include a droplet upload URI", func() {
			BeforeEach(func() {
				var err error
				incomingRequest, err = http.NewRequest("POST", "http://example.com", bytes.NewBufferString(""))
				Expect(err).NotTo(HaveOccurred())
			})

			It("responds with an error code", func() {
				Expect(outgoingResponse.Code).To(Equal(http.StatusBadRequest))
			})
예제 #2
0
func New(uploader ccclient.Uploader, poller ccclient.Poller, logger lager.Logger) (http.Handler, error) {
	return rata.NewRouter(ccuploader.Routes, rata.Handlers{
		ccuploader.UploadDropletRoute:        upload_droplet.New(uploader, poller, logger),
		ccuploader.UploadBuildArtifactsRoute: upload_build_artifacts.New(uploader, logger),
	})
}