mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
integrationtests: remove leftover code for Go 1.19 (#4193)
This commit is contained in:
parent
659da8ca08
commit
a7a66f6437
3 changed files with 41 additions and 86 deletions
|
@ -1,21 +0,0 @@
|
||||||
//go:build go1.19 && !go1.20
|
|
||||||
|
|
||||||
package self_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const go120 = false
|
|
||||||
|
|
||||||
var errNotSupported = errors.New("not supported")
|
|
||||||
|
|
||||||
func setReadDeadline(w http.ResponseWriter, deadline time.Time) error {
|
|
||||||
return errNotSupported
|
|
||||||
}
|
|
||||||
|
|
||||||
func setWriteDeadline(w http.ResponseWriter, deadline time.Time) error {
|
|
||||||
return errNotSupported
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
//go:build go1.20
|
|
||||||
|
|
||||||
package self_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const go120 = true
|
|
||||||
|
|
||||||
func setReadDeadline(w http.ResponseWriter, deadline time.Time) error {
|
|
||||||
rc := http.NewResponseController(w)
|
|
||||||
|
|
||||||
return rc.SetReadDeadline(deadline)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setWriteDeadline(w http.ResponseWriter, deadline time.Time) error {
|
|
||||||
rc := http.NewResponseController(w)
|
|
||||||
|
|
||||||
return rc.SetWriteDeadline(deadline)
|
|
||||||
}
|
|
|
@ -432,55 +432,53 @@ var _ = Describe("HTTP tests", func() {
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
if go120 {
|
It("supports read deadlines", func() {
|
||||||
It("supports read deadlines", func() {
|
mux.HandleFunc("/read-deadline", func(w http.ResponseWriter, r *http.Request) {
|
||||||
mux.HandleFunc("/read-deadline", func(w http.ResponseWriter, r *http.Request) {
|
defer GinkgoRecover()
|
||||||
defer GinkgoRecover()
|
rc := http.NewResponseController(w)
|
||||||
err := setReadDeadline(w, time.Now().Add(deadlineDelay))
|
Expect(rc.SetReadDeadline(time.Now().Add(deadlineDelay))).To(Succeed())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
body, err := io.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||||
Expect(body).To(ContainSubstring("aa"))
|
Expect(body).To(ContainSubstring("aa"))
|
||||||
|
|
||||||
w.Write([]byte("ok"))
|
w.Write([]byte("ok"))
|
||||||
})
|
|
||||||
|
|
||||||
expectedEnd := time.Now().Add(deadlineDelay)
|
|
||||||
resp, err := client.Post(
|
|
||||||
fmt.Sprintf("https://localhost:%d/read-deadline", port),
|
|
||||||
"text/plain",
|
|
||||||
neverEnding('a'),
|
|
||||||
)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
Expect(resp.StatusCode).To(Equal(200))
|
|
||||||
|
|
||||||
body, err := io.ReadAll(gbytes.TimeoutReader(resp.Body, 2*deadlineDelay))
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
Expect(time.Now().After(expectedEnd)).To(BeTrue())
|
|
||||||
Expect(string(body)).To(Equal("ok"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("supports write deadlines", func() {
|
expectedEnd := time.Now().Add(deadlineDelay)
|
||||||
mux.HandleFunc("/write-deadline", func(w http.ResponseWriter, r *http.Request) {
|
resp, err := client.Post(
|
||||||
defer GinkgoRecover()
|
fmt.Sprintf("https://localhost:%d/read-deadline", port),
|
||||||
err := setWriteDeadline(w, time.Now().Add(deadlineDelay))
|
"text/plain",
|
||||||
Expect(err).ToNot(HaveOccurred())
|
neverEnding('a'),
|
||||||
|
)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(resp.StatusCode).To(Equal(200))
|
||||||
|
|
||||||
_, err = io.Copy(w, neverEnding('a'))
|
body, err := io.ReadAll(gbytes.TimeoutReader(resp.Body, 2*deadlineDelay))
|
||||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
Expect(time.Now().After(expectedEnd)).To(BeTrue())
|
||||||
|
Expect(string(body)).To(Equal("ok"))
|
||||||
|
})
|
||||||
|
|
||||||
expectedEnd := time.Now().Add(deadlineDelay)
|
It("supports write deadlines", func() {
|
||||||
|
mux.HandleFunc("/write-deadline", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
rc := http.NewResponseController(w)
|
||||||
|
Expect(rc.SetWriteDeadline(time.Now().Add(deadlineDelay))).To(Succeed())
|
||||||
|
|
||||||
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/write-deadline", port))
|
_, err := io.Copy(w, neverEnding('a'))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||||
Expect(resp.StatusCode).To(Equal(200))
|
|
||||||
|
|
||||||
body, err := io.ReadAll(gbytes.TimeoutReader(resp.Body, 2*deadlineDelay))
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
Expect(time.Now().After(expectedEnd)).To(BeTrue())
|
|
||||||
Expect(string(body)).To(ContainSubstring("aa"))
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
expectedEnd := time.Now().Add(deadlineDelay)
|
||||||
|
|
||||||
|
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/write-deadline", port))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(resp.StatusCode).To(Equal(200))
|
||||||
|
|
||||||
|
body, err := io.ReadAll(gbytes.TimeoutReader(resp.Body, 2*deadlineDelay))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(time.Now().After(expectedEnd)).To(BeTrue())
|
||||||
|
Expect(string(body)).To(ContainSubstring("aa"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue