@@ -196,7 +196,9 @@ describe("wrangler", () => {
196196 describe ( "create" , ( ) => {
197197 function mockCreateRequest (
198198 queueName : string ,
199- queueSettings : { delivery_delay ?: number } | undefined = undefined
199+ queueSettings :
200+ | { delivery_delay ?: number ; message_retention_period ?: number }
201+ | undefined = undefined
200202 ) {
201203 const requests = { count : 0 } ;
202204
@@ -210,6 +212,7 @@ describe("wrangler", () => {
210212 queue_name : string ;
211213 settings : {
212214 delivery_delay : number ;
215+ message_retention_period : number ;
213216 } ;
214217 } ;
215218 expect ( body . queue_name ) . toEqual ( queueName ) ;
@@ -249,7 +252,8 @@ describe("wrangler", () => {
249252 -v, --version Show version number [boolean]
250253
251254 OPTIONS
252- --delivery-delay-secs How long a published message should be delayed for, in seconds. Must be a positive integer [number]"
255+ --delivery-delay-secs How long a published message should be delayed for, in seconds. Must be between 0 and 42300 [number]
256+ --message-retention-period-secs How long to retain a message in the queue, in seconds. Must be between 60 and 1209600 [number]"
253257 ` ) ;
254258 } ) ;
255259 describe . each ( [ "wrangler.json" , "wrangler.toml" ] ) ( "%s" , ( configPath ) => {
@@ -301,18 +305,18 @@ describe("wrangler", () => {
301305 runWrangler ( `queues create ${ queueName } ` )
302306 ) . rejects . toThrowError ( ) ;
303307 expect ( std . out ) . toMatchInlineSnapshot ( `
304- "🌀 Creating queue 'testQueue'
305- Queues is not currently enabled on this account. Go to https://dash.cloudflare.com/some-account-id/workers/queues to enable it.
308+ "🌀 Creating queue 'testQueue'
309+ Queues is not currently enabled on this account. Go to https://dash.cloudflare.com/some-account-id/workers/queues to enable it.
306310
307- [31mX [41;31m[[41;97mERROR[41;31m][0m [1mA request to the Cloudflare API (/accounts/some-account-id/queues) failed.[0m
311+ [31mX [41;31m[[41;97mERROR[41;31m][0m [1mA request to the Cloudflare API (/accounts/some-account-id/queues) failed.[0m
308312
309- workers.api.error.unauthorized [code: 10023]
313+ workers.api.error.unauthorized [code: 10023]
310314
311- If you think this is a bug, please open an issue at:
312- [4mhttps://github.com/cloudflare/workers-sdk/issues/new/choose[0m
315+ If you think this is a bug, please open an issue at:
316+ [4mhttps://github.com/cloudflare/workers-sdk/issues/new/choose[0m
313317
314- "
315- `) ;
318+ "
319+ `) ;
316320 } ) ;
317321
318322 it ( "should show an error when two delivery delays are set" , async ( ) => {
@@ -339,6 +343,76 @@ describe("wrangler", () => {
339343
340344 expect ( requests . count ) . toEqual ( 0 ) ;
341345 } ) ;
346+
347+ it ( "should send queue settings with message retention period" , async ( ) => {
348+ const requests = mockCreateRequest ( "testQueue" , {
349+ message_retention_period : 100 ,
350+ } ) ;
351+ await runWrangler (
352+ "queues create testQueue --message-retention-period-secs=100"
353+ ) ;
354+ expect ( std . out ) . toMatchInlineSnapshot ( `
355+ "🌀 Creating queue 'testQueue'
356+ ✅ Created queue 'testQueue'
357+
358+ Configure your Worker to send messages to this queue:
359+
360+ {
361+ \\"queues\\": {
362+ \\"producers\\": [
363+ {
364+ \\"queue\\": \\"testQueue\\",
365+ \\"binding\\": \\"testQueue\\"
366+ }
367+ ]
368+ }
369+ }
370+ Configure your Worker to consume messages from this queue:
371+
372+ {
373+ \\"queues\\": {
374+ \\"consumers\\": [
375+ {
376+ \\"queue\\": \\"testQueue\\"
377+ }
378+ ]
379+ }
380+ }"
381+ ` ) ;
382+ expect ( requests . count ) . toEqual ( 1 ) ;
383+ } ) ;
384+
385+ it ( "should show an error when two message retention periods are set" , async ( ) => {
386+ const requests = mockCreateRequest ( "testQueue" , {
387+ message_retention_period : 60 ,
388+ } ) ;
389+
390+ await expect (
391+ runWrangler (
392+ "queues create testQueue --message-retention-period-secs=70 --message-retention-period-secs=80"
393+ )
394+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
395+ `[Error: Cannot specify --message-retention-period-secs multiple times]`
396+ ) ;
397+
398+ expect ( requests . count ) . toEqual ( 0 ) ;
399+ } ) ;
400+
401+ it ( "should show an error when invalid message retention period is set" , async ( ) => {
402+ const requests = mockCreateRequest ( "testQueue" , {
403+ message_retention_period : 100 ,
404+ } ) ;
405+ await expect (
406+ runWrangler (
407+ "queues create testQueue --message-retention-period-secs=0"
408+ )
409+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
410+ `[Error: Invalid --message-retention-period-secs value: 0. Must be between 60 and 1209600]`
411+ ) ;
412+
413+ expect ( requests . count ) . toEqual ( 0 ) ;
414+ } ) ;
415+ } ) ;
342416 } ) ;
343417
344418 describe ( "delete" , ( ) => {
0 commit comments