forked from quic-go/quic-go
add an integration test for uploading data with the client
This commit is contained in:
@@ -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()))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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())
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user