aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-10-05 12:12:42 +0200
committerGitHub <noreply@github.com>2022-10-05 12:12:42 +0200
commit8c0c3441d88a612ca8e9ba4f83c6ff29ca73f5d0 (patch)
tree74b355bf97be6ad1b82cf89d16d564105f5373de /test
parentebd137cf6b2fbd767625dc5289b0bef6d1e51971 (diff)
Add `RoomEventType` nats.Header to avoid unneeded unmarshalling (#2765)
Diffstat (limited to 'test')
-rw-r--r--test/testrig/jetstream.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/test/testrig/jetstream.go b/test/testrig/jetstream.go
index 74cf9506..b880eea4 100644
--- a/test/testrig/jetstream.go
+++ b/test/testrig/jetstream.go
@@ -4,10 +4,11 @@ import (
"encoding/json"
"testing"
+ "github.com/nats-io/nats.go"
+
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/base"
"github.com/matrix-org/dendrite/setup/jetstream"
- "github.com/nats-io/nats.go"
)
func MustPublishMsgs(t *testing.T, jsctx nats.JetStreamContext, msgs ...*nats.Msg) {
@@ -21,10 +22,8 @@ func MustPublishMsgs(t *testing.T, jsctx nats.JetStreamContext, msgs ...*nats.Ms
func NewOutputEventMsg(t *testing.T, base *base.BaseDendrite, roomID string, update api.OutputEvent) *nats.Msg {
t.Helper()
- msg := &nats.Msg{
- Subject: base.Cfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent),
- Header: nats.Header{},
- }
+ msg := nats.NewMsg(base.Cfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent))
+ msg.Header.Set(jetstream.RoomEventType, string(update.Type))
msg.Header.Set(jetstream.RoomID, roomID)
var err error
msg.Data, err = json.Marshal(update)