예제 #1
0
						})

						It("errors", func() {
							Eventually(pollErrChan).Should(Receive(MatchError("upstream request was cancelled")))
						})
					})

					Context("during a request", func() {
						var cancelChan chan struct{}

						BeforeEach(func() {
							pollRequestChan = make(chan *http.Request)
							cancelChan = make(chan struct{})
							transport = test_helpers.NewFakeRoundTripper(
								pollRequestChan,
								map[string]test_helpers.RespErrorPair{
									"example.com": {responseWithBody(pollingResponseBody("http://example.com", ccclient.JOB_QUEUED)), nil},
								},
							)
						})

						It("errors", func() {
							Eventually(pollRequestChan).Should(Receive())
							close(cancelChan)
							Eventually(pollRequestChan).Should(Receive())
							Eventually(pollErrChan).Should(Receive(HaveOccurred()))
						})
					})
				})

				Context("when the metadata URL can't be parsed", func() {
					BeforeEach(func() {
예제 #2
0
				It("fails early if the content length is 0", func() {
					Expect(response.StatusCode).To(Equal(http.StatusLengthRequired))

					Expect(uploadErr).To(HaveOccurred())
				})
			})

			Context("When it can create a valid multipart request to the upload URL", func() {
				var uploadRequestChan chan *http.Request

				BeforeEach(func() {
					uploadRequestChan = make(chan *http.Request, 3)
					transport = test_helpers.NewFakeRoundTripper(
						uploadRequestChan,
						map[string]test_helpers.RespErrorPair{
							"example.com": {responseWithCode(http.StatusOK), nil},
						},
					)
				})

				It("Makes an upload request using that multipart request", func() {
					var uploadRequest *http.Request
					Eventually(uploadRequestChan).Should(Receive(&uploadRequest))
					Expect(uploadRequest.Header.Get("Content-Type")).To(ContainSubstring("multipart/form-data; boundary="))
				})

				It("Forwards Content-MD5 header onto the upload request", func() {
					var uploadRequest *http.Request
					Eventually(uploadRequestChan).Should(Receive(&uploadRequest))
					Expect(uploadRequest.Header.Get("Content-MD5")).To(Equal("the-md5"))
				})