move all frames to separate package

This commit is contained in:
Marten Seemann
2016-04-16 18:34:16 +07:00
parent 88f404c19e
commit 79ba43bbdb
12 changed files with 36 additions and 21 deletions

View File

@@ -0,0 +1,30 @@
package frames
import (
"bytes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("AckFrame", func() {
Context("when parsing", func() {
It("accepts sample frame", func() {
b := bytes.NewReader([]byte{0x40, 0x19, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x4e, 0x6f, 0x20, 0x72, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e})
frame, err := ParseConnectionCloseFrame(b)
Expect(err).ToNot(HaveOccurred())
Expect(frame.ErrorCode).To(Equal(uint32(0x19)))
Expect(frame.ReasonPhrase).To(Equal("No recent network activity."))
Expect(b.Len()).To(Equal(0))
})
It("parses a frame without a reason phrase", func() {
b := bytes.NewReader([]byte{0x02, 0xAD, 0xFB, 0xCA, 0xDE, 0x00, 0x00})
frame, err := ParseConnectionCloseFrame(b)
Expect(err).ToNot(HaveOccurred())
Expect(frame.ErrorCode).To(Equal(uint32(0xDECAFBAD)))
Expect(len(frame.ReasonPhrase)).To(Equal(0))
Expect(b.Len()).To(Equal(0))
})
})
})