github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/protocol/v1/reply_test.go (about) 1 // Copyright (c) 2017-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package v1 6 7 import ( 8 "time" 9 10 "github.com/choria-io/go-choria/protocol" 11 . "github.com/onsi/ginkgo/v2" 12 . "github.com/onsi/gomega" 13 ) 14 15 var _ = Describe("Reply", func() { 16 It("should create the correct reply from a request", func() { 17 request, err := NewRequest("test", "go.tests", "choria=test", 120, "a2f0ca717c694f2086cfa81b6c494648", "mcollective") 18 request.SetMessage([]byte("hello world")) 19 20 Expect(err).ToNot(HaveOccurred()) 21 reply, err := NewReply(request, "testing") 22 Expect(err).ToNot(HaveOccurred()) 23 24 reply.SetMessage([]byte("hello world")) 25 j, _ := reply.JSON() 26 27 Expect(protocol.VersionFromJSON(j)).To(Equal(protocol.ReplyV1)) 28 Expect(reply.Message()).To(Equal([]byte("hello world"))) 29 Expect(reply.RequestID()).To(HaveLen(32)) 30 Expect(reply.SenderID()).To(Equal("testing")) 31 Expect(reply.Agent()).To(Equal("test")) 32 Expect(reply.Time()).To(BeTemporally("~", time.Now(), time.Second)) 33 }) 34 })