From 06aa2489ba6a913ed631332447dd9d31e1eafc69 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 16 Jan 2017 15:23:23 +0700 Subject: [PATCH] add an integration test for uploading data with the client --- integrationtests/client_test.go | 12 ++++++++++++ integrationtests/integrationtests_suite_test.go | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/integrationtests/client_test.go b/integrationtests/client_test.go index ee394185..c0ea7642 100644 --- a/integrationtests/client_test.go +++ b/integrationtests/client_test.go @@ -1,6 +1,7 @@ package integrationtests import ( + "bytes" "io/ioutil" "net/http" "os" @@ -49,4 +50,15 @@ var _ = Describe("Client tests", func() { Expect(err).ToNot(HaveOccurred()) Expect(body).To(Equal(dataMan.GetData())) }) + + It("uploads a file", func() { + dataMan.GenerateData(dataLen) + data := bytes.NewReader(dataMan.GetData()) + resp, err := client.Post("https://quic.clemente.io:"+port+"/echo", "text/plain", data) + Expect(err).ToNot(HaveOccurred()) + Expect(resp.StatusCode).To(Equal(200)) + body, err := ioutil.ReadAll(resp.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(body).To(Equal(dataMan.GetData())) + }) }) diff --git a/integrationtests/integrationtests_suite_test.go b/integrationtests/integrationtests_suite_test.go index 32c54eb5..8cfb22ca 100644 --- a/integrationtests/integrationtests_suite_test.go +++ b/integrationtests/integrationtests_suite_test.go @@ -100,7 +100,9 @@ func setupHTTPHandlers() { http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() - _, err := io.Copy(w, r.Body) + body, err := ioutil.ReadAll(r.Body) + Expect(err).NotTo(HaveOccurred()) + _, err = w.Write(body) Expect(err).NotTo(HaveOccurred()) })