fix flaky h2quic client test

This commit is contained in:
Marten Seemann
2017-01-16 11:04:54 +07:00
parent 1eeb249876
commit f08e00630d

View File

@@ -151,9 +151,6 @@ var _ = Describe("Client", func() {
})
It("closes the quic client when encountering an error on the header stream", func() {
headerStream.dataToRead.Write([]byte("invalid response"))
go client.handleHeaderStream()
var doRsp *http.Response
var doErr error
var doReturned bool
@@ -162,6 +159,15 @@ var _ = Describe("Client", func() {
doReturned = true
}()
Eventually(func() chan *http.Response {
client.mutex.RLock()
defer client.mutex.RUnlock()
return client.responses[5]
}).ShouldNot(BeNil())
headerStream.dataToRead.Write([]byte("invalid response"))
client.handleHeaderStream()
Eventually(func() bool { return doReturned }).Should(BeTrue())
Expect(client.headerErr).To(HaveOccurred())
Expect(doErr).To(MatchError(client.headerErr))