(t *testing.T)
| 1288 | } |
| 1289 | |
| 1290 | func 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", |
nothing calls this directly
no test coverage detected