mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +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())
|
||||
})
|
||||
|
||||
if go120 {
|
||||
It("supports read deadlines", func() {
|
||||
mux.HandleFunc("/read-deadline", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
err := setReadDeadline(w, time.Now().Add(deadlineDelay))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
It("supports read deadlines", func() {
|
||||
mux.HandleFunc("/read-deadline", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
rc := http.NewResponseController(w)
|
||||
Expect(rc.SetReadDeadline(time.Now().Add(deadlineDelay))).To(Succeed())
|
||||
|
||||
body, err := io.ReadAll(r.Body)
|
||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||
Expect(body).To(ContainSubstring("aa"))
|
||||
body, err := io.ReadAll(r.Body)
|
||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||
Expect(body).To(ContainSubstring("aa"))
|
||||
|
||||
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"))
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
|
||||
It("supports write deadlines", func() {
|
||||
mux.HandleFunc("/write-deadline", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
err := setWriteDeadline(w, time.Now().Add(deadlineDelay))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
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))
|
||||
|
||||
_, err = io.Copy(w, neverEnding('a'))
|
||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||
})
|
||||
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"))
|
||||
})
|
||||
|
||||
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))
|
||||
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"))
|
||||
_, err := io.Copy(w, neverEnding('a'))
|
||||
Expect(err).To(MatchError(os.ErrDeadlineExceeded))
|
||||
})
|
||||
}
|
||||
|
||||
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