Merge pull request #3575 from MichaelEischer/adjust-http2-canary-test

rest: Adjust http2-missing-eof test to golang >= 1.17.3
This commit is contained in:
MichaelEischer 2021-11-13 22:13:24 +01:00 committed by GitHub
commit 1d8a0b06cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 28 deletions

View File

@ -1,4 +1,9 @@
// +build go1.14
//go:build go1.14 && !go1.18
// +build go1.14,!go1.18
// missing eof error is fixed in golang >= 1.17.3 or >= 1.16.10
// remove the workaround from rest.go when the minimum golang version
// supported by restic reaches 1.18.
package rest_test
@ -65,30 +70,3 @@ func TestZeroLengthRead(t *testing.T) {
t.Fatal("Got no unexpected EOF error")
}
}
func TestGolangZeroLengthRead(t *testing.T) {
// This test is intended to fail once the underlying issue has been fixed in Go
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", "42")
// Now the handler fails for some reason and is unable to send data
}))
ts.EnableHTTP2 = true
ts.StartTLS()
defer ts.Close()
res, err := ts.Client().Get(ts.URL)
if err != nil {
t.Fatal(err)
}
_, err = ioutil.ReadAll(res.Body)
defer func() {
err = res.Body.Close()
if err != nil {
t.Fatal(err)
}
}()
if err != nil {
// This should fail with an 'Unexpected EOF' error
t.Fatal(err)
}
}