forked from quic-go/quic-go
49 lines
911 B
Go
49 lines
911 B
Go
package http3
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func TestHttp3(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "HTTP/3 Suite")
|
|
}
|
|
|
|
func mustNewRequest(method, url string, body io.Reader) *http.Request {
|
|
req, err := http.NewRequest(method, url, body)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return req
|
|
}
|
|
|
|
var mockCtrl *gomock.Controller
|
|
|
|
var _ = BeforeEach(func() {
|
|
mockCtrl = gomock.NewController(GinkgoT())
|
|
})
|
|
|
|
var _ = AfterEach(func() {
|
|
mockCtrl.Finish()
|
|
})
|
|
|
|
func scaleDuration(t time.Duration) time.Duration {
|
|
scaleFactor := 1
|
|
if f, err := strconv.Atoi(os.Getenv("TIMESCALE_FACTOR")); err == nil { // parsing "" errors, so this works fine if the env is not set
|
|
scaleFactor = f
|
|
}
|
|
if scaleFactor == 0 {
|
|
panic("TIMESCALE_FACTOR is 0")
|
|
}
|
|
return time.Duration(scaleFactor) * t
|
|
}
|