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

Function TestJetStream_CreateOrUpdateConsumer

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

Source from the content-addressed store, hash-verified

1288}
1289
1290func TestJetStream_CreateOrUpdateConsumer(t *testing.T) {
1291 tests := []struct {
1292 name string
1293 stream string
1294 consumerConfig jetstream.ConsumerConfig
1295 shouldCreate bool
1296 timeout time.Duration
1297 withError error
1298 }{
1299 {
1300 name: "create durable pull consumer",
1301 stream: "foo",
1302 consumerConfig: jetstream.ConsumerConfig{Durable: "dur", AckPolicy: jetstream.AckExplicitPolicy},
1303 timeout: 10 * time.Second,
1304 shouldCreate: true,
1305 },
1306 {
1307 name: "create ephemeral pull consumer",
1308 stream: "foo",
1309 consumerConfig: jetstream.ConsumerConfig{AckPolicy: jetstream.AckExplicitPolicy},
1310 timeout: 10 * time.Second,
1311 shouldCreate: true,
1312 },
1313 {
1314 name: "with empty context",
1315 consumerConfig: jetstream.ConsumerConfig{AckPolicy: jetstream.AckExplicitPolicy},
1316 stream: "foo",
1317 shouldCreate: true,
1318 },
1319 {
1320 name: "consumer already exists, update",
1321 stream: "foo",
1322 consumerConfig: jetstream.ConsumerConfig{Durable: "dur", AckPolicy: jetstream.AckExplicitPolicy, Description: "test consumer"},
1323 },
1324 {
1325 name: "consumer already exists, illegal update",
1326 stream: "foo",
1327 consumerConfig: jetstream.ConsumerConfig{Durable: "dur", AckPolicy: jetstream.AckNonePolicy, Description: "test consumer"},
1328 withError: jetstream.ErrConsumerCreate,
1329 },
1330 {
1331 name: "stream does not exist",
1332 stream: "abc",
1333 withError: jetstream.ErrStreamNotFound,
1334 },
1335 {
1336 name: "invalid stream name",
1337 stream: "foo.1",
1338 withError: jetstream.ErrInvalidStreamName,
1339 },
1340 {
1341 name: "invalid durable name",
1342 stream: "foo",
1343 consumerConfig: jetstream.ConsumerConfig{Durable: "dur.123", AckPolicy: jetstream.AckExplicitPolicy},
1344 withError: jetstream.ErrInvalidConsumerName,
1345 },
1346 {
1347 name: "context timeout",

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
ConsumerMethod · 0.65

Tested by

no test coverage detected