From cdcb4163c0527eea4f5867f9d90c93c836098dc1 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 15 Jan 2017 13:36:42 +0700 Subject: [PATCH] add a simple integration test for the client --- .travis.yml | 4 ++++ integrationtests/client_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 integrationtests/client_test.go diff --git a/.travis.yml b/.travis.yml index 66f02d9f..868f0dd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ sudo: required +addons: + hosts: + - quic.clemente.io + language: go services: diff --git a/integrationtests/client_test.go b/integrationtests/client_test.go new file mode 100644 index 00000000..12c8ce9f --- /dev/null +++ b/integrationtests/client_test.go @@ -0,0 +1,32 @@ +package integrationtests + +import ( + "io/ioutil" + "net/http" + "os" + + "github.com/lucas-clemente/quic-go/h2quic" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Client tests", func() { + var client *http.Client + + BeforeEach(func() { + err := os.Setenv("HOSTALIASES", "quic.clemente.io 127.0.0.1") + Expect(err).ToNot(HaveOccurred()) + client = &http.Client{ + Transport: &h2quic.QuicRoundTripper{}, + } + }) + + It("downloads a hello", func() { + resp, err := client.Get("https://quic.clemente.io:" + port + "/hello") + Expect(err).ToNot(HaveOccurred()) + Expect(resp.StatusCode).To(Equal(200)) + body, err := ioutil.ReadAll(resp.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(string(body)).To(Equal("Hello, World!\n")) + }) +})