Skip to content

Commit

Permalink
new: test for mpack closemessage
Browse files Browse the repository at this point in the history
  • Loading branch information
philippseith committed Apr 6, 2024
1 parent b743eb6 commit 682515d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions messagepackhubprotocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,21 @@ var _ = Describe("MessagePackHubProtocol", func() {
Expect(gotMsg.Type).To(Equal(message.Type))
Expect(gotMsg.InvocationID).To(Equal(message.InvocationID))
})
It("should encode/decode an CloseMessage", func() {
message := closeMessage{
Type: 7,
}
buf := bytes.Buffer{}
err := protocol.WriteMessage(message, &buf)
Expect(err).NotTo(HaveOccurred())
remainBuf := bytes.Buffer{}
got, err := protocol.ParseMessages(&buf, &remainBuf)
Expect(err).NotTo(HaveOccurred())
Expect(remainBuf.Len()).To(Equal(0))
Expect(len(got)).To(Equal(1))
Expect(got[0]).To(BeAssignableToTypeOf(closeMessage{}))
gotMsg := got[0].(closeMessage)
Expect(gotMsg.Type).To(Equal(message.Type))
})
})
})

0 comments on commit 682515d

Please sign in to comment.