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

Function TestListStreams

jetstream/test/jetstream_test.go:1095–1190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1093}
1094
1095func TestListStreams(t *testing.T) {
1096 tests := []struct {
1097 name string
1098 streamsNum int
1099 timeout time.Duration
1100 subject string
1101 expected int
1102 withError error
1103 }{
1104 {
1105 name: "list streams",
1106 streamsNum: 260,
1107 timeout: 10 * time.Second,
1108 expected: 260,
1109 },
1110 {
1111 name: "with empty context",
1112 streamsNum: 260,
1113 expected: 260,
1114 },
1115 {
1116 name: "no stream available",
1117 timeout: 10 * time.Second,
1118 streamsNum: 0,
1119 expected: 0,
1120 },
1121 {
1122 name: "list streams with subject filter",
1123 subject: "FOO.123",
1124 streamsNum: 260,
1125 expected: 1,
1126 },
1127 {
1128 name: "list streams with subject filter, no match",
1129 subject: "FOO.500",
1130 streamsNum: 100,
1131 expected: 0,
1132 },
1133 {
1134 name: "context timeout",
1135 streamsNum: 260,
1136 timeout: 1 * time.Microsecond,
1137 withError: context.DeadlineExceeded,
1138 },
1139 }
1140
1141 for _, test := range tests {
1142 t.Run(test.name, func(t *testing.T) {
1143 srv := RunBasicJetStreamServer()
1144 defer shutdownJSServerAndRemoveStorage(t, srv)
1145 nc, err := nats.Connect(srv.ClientURL())
1146 if err != nil {
1147 t.Fatalf("Unexpected error: %v", err)
1148 }
1149
1150 ctx := context.Background()
1151 if test.timeout > 0 {
1152 var cancel context.CancelFunc

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
WithStreamListSubjectFunction · 0.92
ConnectMethod · 0.80
FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
CreateStreamMethod · 0.65
ListStreamsMethod · 0.65
InfoMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected