move utils.Stream to quic.Stream

This commit is contained in:
Marten Seemann 2017-02-20 18:05:49 +07:00
parent 592ef45fdf
commit cd465ae0b5
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
17 changed files with 73 additions and 80 deletions

View file

@ -8,7 +8,6 @@ import (
"github.com/lucas-clemente/quic-go/handshake"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/qerr"
"github.com/lucas-clemente/quic-go/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@ -296,7 +295,7 @@ var _ = Describe("Streams Map", func() {
})
It("accepts stream 1 first", func() {
var str utils.Stream
var str *stream
go func() {
defer GinkgoRecover()
var err error
@ -305,12 +304,12 @@ var _ = Describe("Streams Map", func() {
}()
_, err := m.GetOrOpenStream(1)
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str }).ShouldNot(BeNil())
Eventually(func() Stream { return str }).ShouldNot(BeNil())
Expect(str.StreamID()).To(Equal(protocol.StreamID(1)))
})
It("returns an implicitly opened stream, if a stream number is skipped", func() {
var str utils.Stream
var str *stream
go func() {
defer GinkgoRecover()
var err error
@ -319,12 +318,12 @@ var _ = Describe("Streams Map", func() {
}()
_, err := m.GetOrOpenStream(5)
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str }).ShouldNot(BeNil())
Eventually(func() Stream { return str }).ShouldNot(BeNil())
Expect(str.StreamID()).To(Equal(protocol.StreamID(1)))
})
It("returns to multiple accepts", func() {
var str1, str2 utils.Stream
var str1, str2 *stream
go func() {
defer GinkgoRecover()
var err error
@ -339,29 +338,29 @@ var _ = Describe("Streams Map", func() {
}()
_, err := m.GetOrOpenStream(3) // opens stream 1 and 3
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str1 }).ShouldNot(BeNil())
Eventually(func() utils.Stream { return str2 }).ShouldNot(BeNil())
Eventually(func() *stream { return str1 }).ShouldNot(BeNil())
Eventually(func() *stream { return str2 }).ShouldNot(BeNil())
Expect(str1.StreamID()).ToNot(Equal(str2.StreamID()))
Expect(str1.StreamID() + str2.StreamID()).To(BeEquivalentTo(1 + 3))
})
It("waits a new stream is available", func() {
var str utils.Stream
var str *stream
go func() {
defer GinkgoRecover()
var err error
str, err = m.AcceptStream()
Expect(err).ToNot(HaveOccurred())
}()
Consistently(func() utils.Stream { return str }).Should(BeNil())
Consistently(func() *stream { return str }).Should(BeNil())
_, err := m.GetOrOpenStream(1)
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str }).ShouldNot(BeNil())
Eventually(func() *stream { return str }).ShouldNot(BeNil())
Expect(str.StreamID()).To(Equal(protocol.StreamID(1)))
})
It("returns multiple streams on subsequent Accept calls, if available", func() {
var str utils.Stream
var str *stream
go func() {
defer GinkgoRecover()
var err error
@ -370,7 +369,7 @@ var _ = Describe("Streams Map", func() {
}()
_, err := m.GetOrOpenStream(3)
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str }).ShouldNot(BeNil())
Eventually(func() *stream { return str }).ShouldNot(BeNil())
Expect(str.StreamID()).To(Equal(protocol.StreamID(1)))
str, err = m.AcceptStream()
Expect(err).ToNot(HaveOccurred())
@ -461,7 +460,7 @@ var _ = Describe("Streams Map", func() {
Context("accepting streams", func() {
It("accepts stream 2 first", func() {
var str utils.Stream
var str *stream
go func() {
defer GinkgoRecover()
var err error
@ -470,7 +469,7 @@ var _ = Describe("Streams Map", func() {
}()
_, err := m.GetOrOpenStream(2)
Expect(err).ToNot(HaveOccurred())
Eventually(func() utils.Stream { return str }).ShouldNot(BeNil())
Eventually(func() *stream { return str }).ShouldNot(BeNil())
Expect(str.StreamID()).To(Equal(protocol.StreamID(2)))
})
})