forked from quic-go/quic-go
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package integrationtests
|
|
|
|
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, "Integration 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())
|
|
})
|
|
}
|