forked from quic-go/quic-go
Move rest of integration tests into the gquic folder
This commit is contained in:
69
integrationtests/gquic/gquic_suite_test.go
Normal file
69
integrationtests/gquic/gquic_suite_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package gquic_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
_ "github.com/lucas-clemente/quic-go/integrationtests/tools/testlog"
|
||||
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
const (
|
||||
dataLen = 500 * 1024 // 500 KB
|
||||
dataLongLen = 50 * 1024 * 1024 // 50 MB
|
||||
)
|
||||
|
||||
var (
|
||||
dataMan dataManager
|
||||
clientPath string
|
||||
serverPath string
|
||||
)
|
||||
|
||||
func TestIntegration(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "GQuic Tests Suite")
|
||||
}
|
||||
|
||||
var _ = JustBeforeEach(testserver.StartQuicServer)
|
||||
|
||||
var _ = AfterEach(testserver.StopQuicServer)
|
||||
|
||||
func init() {
|
||||
_, thisfile, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
panic("Failed to get current path")
|
||||
}
|
||||
clientPath = filepath.Join(thisfile, fmt.Sprintf("../../../../quic-clients/client-%s-debug", runtime.GOOS))
|
||||
serverPath = filepath.Join(thisfile, fmt.Sprintf("../../../../quic-clients/server-%s-debug", runtime.GOOS))
|
||||
|
||||
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
_, err := io.WriteString(w, "Hello, World!\n")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
http.HandleFunc("/data", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
data := dataMan.GetData()
|
||||
Expect(data).ToNot(HaveLen(0))
|
||||
_, err := w.Write(data)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
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