From b743eb6060519d4172444de688949c082d37b978 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 6 Apr 2024 18:53:13 +0200 Subject: [PATCH] new: test for cancelInvocationMessage --- messagepackhubprotocol_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/messagepackhubprotocol_test.go b/messagepackhubprotocol_test.go index 4b327158..4d09671d 100644 --- a/messagepackhubprotocol_test.go +++ b/messagepackhubprotocol_test.go @@ -44,5 +44,23 @@ var _ = Describe("MessagePackHubProtocol", func() { Expect(reflect.Indirect(value).Interface()).To(Equal(message.Arguments[i])) } }) + It("should encode/decode an CancelInvocationMessage", func() { + message := cancelInvocationMessage{ + Type: 5, + InvocationID: "1", + } + 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(cancelInvocationMessage{})) + gotMsg := got[0].(cancelInvocationMessage) + Expect(gotMsg.Type).To(Equal(message.Type)) + Expect(gotMsg.InvocationID).To(Equal(message.InvocationID)) + }) }) })