From 682515dbf9ccabe04d15ba884d717252ed1db5bb Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 6 Apr 2024 18:54:52 +0200 Subject: [PATCH] new: test for mpack closemessage --- messagepackhubprotocol_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/messagepackhubprotocol_test.go b/messagepackhubprotocol_test.go index 4d09671..7566c75 100644 --- a/messagepackhubprotocol_test.go +++ b/messagepackhubprotocol_test.go @@ -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)) + }) }) })