test all supported quic versions in integration tests

ref #152
This commit is contained in:
Lucas Clemente
2016-06-02 12:05:24 +02:00
parent 0900b5ba73
commit 93629bc595

View File

@@ -7,9 +7,11 @@ import (
"os"
"os/exec"
"runtime"
"strconv"
"time"
"github.com/lucas-clemente/quic-go/h2quic"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/testdata"
_ "github.com/lucas-clemente/quic-clients" // download clients
@@ -30,18 +32,16 @@ var _ = Describe("Integration tests", func() {
clientPath string
)
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello, World!\n")
})
BeforeSuite(func() {
clientPath = fmt.Sprintf(
"%s/src/github.com/lucas-clemente/quic-clients/client-%s-debug",
os.Getenv("GOPATH"),
runtime.GOOS,
)
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello, World!\n")
})
})
BeforeEach(func() {
server = &h2quic.Server{
Server: &http.Server{
Addr: addr,
@@ -55,22 +55,26 @@ var _ = Describe("Integration tests", func() {
time.Sleep(10 * time.Millisecond)
})
AfterEach(func() {
AfterSuite(func() {
err := server.Close()
Expect(err).NotTo(HaveOccurred())
})
It("downloads a single file", func() {
command := exec.Command(
clientPath,
"--quic-version=32",
"--host="+host,
"--port="+port,
"https://quic.clemente.io/hello",
)
session, err := Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(Exit(0))
Expect(session.Out).To(Say("Hello, World!\n"))
})
for _, version := range protocol.SupportedVersions {
Context(fmt.Sprintf("with quic version %d", version), func() {
It("downloads a single file", func() {
command := exec.Command(
clientPath,
"--quic-version="+strconv.Itoa(int(version)),
"--host="+host,
"--port="+port,
"https://quic.clemente.io/hello",
)
session, err := Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(Exit(0))
Expect(session.Out).To(Say("Response:\nheaders: HTTP/1.1 200\nstatus: 200\n\nbody: Hello, World!\n"))
})
})
}
})