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

Function TestCreateConsumer

jetstream/test/stream_test.go:166–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

164}
165
166func TestCreateConsumer(t *testing.T) {
167 tests := []struct {
168 name string
169 consumerConfig jetstream.ConsumerConfig
170 shouldCreate bool
171 withError error
172 }{
173 {
174 name: "create durable consumer",
175 consumerConfig: jetstream.ConsumerConfig{Durable: "dur"},
176 shouldCreate: true,
177 },
178 {
179 name: "idempotent create, no error",
180 consumerConfig: jetstream.ConsumerConfig{Durable: "dur"},
181 shouldCreate: true,
182 },
183 {
184 name: "create ephemeral pull consumer",
185 consumerConfig: jetstream.ConsumerConfig{AckPolicy: jetstream.AckNonePolicy},
186 shouldCreate: true,
187 },
188 {
189 name: "with filter subject",
190 consumerConfig: jetstream.ConsumerConfig{FilterSubject: "FOO.A"},
191 shouldCreate: true,
192 },
193 {
194 name: "with metadata",
195 consumerConfig: jetstream.ConsumerConfig{Metadata: map[string]string{"foo": "bar", "baz": "quux"}},
196 shouldCreate: true,
197 },
198 {
199 name: "with multiple filter subjects",
200 consumerConfig: jetstream.ConsumerConfig{FilterSubjects: []string{"FOO.A", "FOO.B"}},
201 shouldCreate: true,
202 },
203 {
204 name: "with multiple filter subjects, overlapping subjects",
205 consumerConfig: jetstream.ConsumerConfig{FilterSubjects: []string{"FOO.*", "FOO.B"}},
206 withError: jetstream.ErrOverlappingFilterSubjects,
207 },
208 {
209 name: "with multiple filter subjects and filter subject provided",
210 consumerConfig: jetstream.ConsumerConfig{FilterSubjects: []string{"FOO.A", "FOO.B"}, FilterSubject: "FOO.C"},
211 withError: jetstream.ErrDuplicateFilterSubjects,
212 },
213 {
214 name: "with empty subject in FilterSubjects",
215 consumerConfig: jetstream.ConsumerConfig{FilterSubjects: []string{"FOO.A", ""}},
216 withError: jetstream.ErrEmptyFilter,
217 },
218 {
219 name: "with invalid filter subject, leading dot",
220 consumerConfig: jetstream.ConsumerConfig{FilterSubject: ".foo"},
221 withError: jetstream.ErrInvalidSubject,
222 },
223 {

Callers

nothing calls this directly

Calls 15

NextMsgWithContextMethod · 0.95
CachedInfoMethod · 0.95
NewFunction · 0.92
ConnectMethod · 0.80
FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
CreateStreamMethod · 0.65
SubscribeSyncMethod · 0.65
CreateConsumerMethod · 0.65
CreatePushConsumerMethod · 0.65
ConsumerMethod · 0.65

Tested by

no test coverage detected