MCPcopy
hub / github.com/nats-io/nats.go / TestPublishMsg

Function TestPublishMsg

jetstream/test/publish_test.go:31–665  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestPublishMsg(t *testing.T) {
32 type publishConfig struct {
33 msg *nats.Msg
34 opts []jetstream.PublishOpt
35 expectedHeaders nats.Header
36 expectedAck jetstream.PubAck
37 withError func(*testing.T, error)
38 }
39 tests := []struct {
40 name string
41 srvConfig []byte
42 timeout time.Duration
43 msgs []publishConfig
44 }{
45 {
46 name: "publish 3 simple messages, no opts",
47 msgs: []publishConfig{
48 {
49 msg: &nats.Msg{
50 Data: []byte("msg 1"),
51 Subject: "FOO.1",
52 },
53 expectedAck: jetstream.PubAck{
54 Stream: "foo",
55 Sequence: 1,
56 Domain: "",
57 },
58 },
59 {
60 msg: &nats.Msg{
61 Data: []byte("msg 2"),
62 Subject: "FOO.1",
63 },
64 expectedAck: jetstream.PubAck{
65 Stream: "foo",
66 Sequence: 2,
67 Domain: "",
68 },
69 },
70 {
71 msg: &nats.Msg{
72 Data: []byte("msg 3"),
73 Subject: "FOO.2",
74 },
75 expectedAck: jetstream.PubAck{
76 Stream: "foo",
77 Sequence: 3,
78 Domain: "",
79 },
80 },
81 },
82 },
83 {
84 name: "publish 3 messages with message ID, with duplicate",
85 msgs: []publishConfig{
86 {
87 msg: &nats.Msg{
88 Data: []byte("msg 1"),

Callers

nothing calls this directly

Calls 15

WithMsgIDFunction · 0.92
WithExpectLastMsgIDFunction · 0.92
WithExpectLastSequenceFunction · 0.92
WithExpectStreamFunction · 0.92
WithStallWaitFunction · 0.92
NewFunction · 0.92
FatalfMethod · 0.80
ConnectMethod · 0.80
createConfFileFunction · 0.70
RunServerWithConfigFunction · 0.70

Tested by

no test coverage detected