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

Function TestPublishMsgAsync

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

Source from the content-addressed store, hash-verified

893}
894
895func TestPublishMsgAsync(t *testing.T) {
896 type publishConfig struct {
897 msg *nats.Msg
898 opts []jetstream.PublishOpt
899 expectedHeaders nats.Header
900 expectedAck jetstream.PubAck
901 withAckError func(*testing.T, error)
902 withPublishError func(*testing.T, error)
903 }
904 tests := []struct {
905 name string
906 msgs []publishConfig
907 srvConfig []byte
908 timeout time.Duration
909 }{
910 {
911 name: "publish 3 simple messages, no opts",
912 msgs: []publishConfig{
913 {
914 msg: &nats.Msg{
915 Data: []byte("msg 1"),
916 Subject: "FOO.1",
917 },
918 expectedAck: jetstream.PubAck{
919 Stream: "foo",
920 Sequence: 1,
921 Domain: "",
922 },
923 },
924 {
925 msg: &nats.Msg{
926 Data: []byte("msg 2"),
927 Subject: "FOO.1",
928 },
929 expectedAck: jetstream.PubAck{
930 Stream: "foo",
931 Sequence: 2,
932 Domain: "",
933 },
934 },
935 {
936 msg: &nats.Msg{
937 Data: []byte("msg 3"),
938 Subject: "FOO.2",
939 },
940 expectedAck: jetstream.PubAck{
941 Stream: "foo",
942 Sequence: 3,
943 Domain: "",
944 },
945 },
946 },
947 },
948 {
949 name: "publish with ack timeout set",
950 msgs: []publishConfig{
951 {
952 msg: &nats.Msg{

Callers

nothing calls this directly

Calls 15

WithMsgIDFunction · 0.92
WithExpectLastMsgIDFunction · 0.92
WithExpectLastSequenceFunction · 0.92
WithExpectStreamFunction · 0.92
WithRetryAttemptsFunction · 0.92
WithRetryWaitFunction · 0.92
WithStallWaitFunction · 0.92
WithPublishAsyncTimeoutFunction · 0.92
NewFunction · 0.92
FatalfMethod · 0.80

Tested by

no test coverage detected