Skip to content

Commit

Permalink
PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiguel committed Feb 27, 2024
1 parent 2806801 commit 77a75c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
13 changes: 5 additions & 8 deletions packages/wrangler/src/__tests__/queues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,9 @@ describe("wrangler", () => {
it("should show an error with delivery delay and no delivery delay are used", async () => {
const requests = mockCreateRequest("testQueue", { delivery_delay: 0 });

await expect(
runWrangler(
"queues create testQueue --no-delivery-delay --delivery-delay=10"
)
).rejects.toThrowError(
`Error: can't use --no-delivery-delay with --delivery-delay`
expect(
runWrangler("queues create testQueue --no-delivery-delay --delivery-delay=10"))
.toThrowErrorMatchingInlineSnapshot(`"Error: can't use --no-delivery-delay with --delivery-delay"`
);

expect(requests.count).toEqual(0);
Expand Down Expand Up @@ -519,8 +516,8 @@ describe("wrangler", () => {
runWrangler(
"queues consumer add testQueue testScript --env myEnv --batch-size 20 --batch-timeout 10 --message-retries 3 --max-concurrency 3 --dead-letter-queue myDLQ --no-retry-delay --retry-delay=10"
)
).rejects.toThrowError(
`Error: can't use --no-retry-delay with --retry-delay`
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Error: can't use --no-retry-delay with --retry-delay"`
);

expect(requests.count).toEqual(0);
Expand Down
7 changes: 4 additions & 3 deletions packages/wrangler/src/queues/cli/commands/consumer/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export function options(yargs: CommonYargsArgv) {
describe: "Sets retried messages have no delay.",
boolean: true
},
});
})
.conflicts('retry-delay', 'no-retry-delay')
}

function createBody(args: StrictYargsOptionsToInterface<typeof options>): PostConsumerBody {
const body = {
const body: PostConsumerBody = {
script_name: args.scriptName,
// TODO(soon) is this still the correct usage of the environment?
environment_name: args.env ?? "", // API expects empty string as default
Expand All @@ -68,7 +69,7 @@ function createBody(args: StrictYargsOptionsToInterface<typeof options>): PostCo
max_concurrency: args.maxConcurrency,
},
dead_letter_queue: args.deadLetterQueue,
} as PostConsumerBody;
};


// Workaround, Yargs does not play nicely with both --parameter and --no-parameter set.
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/queues/cli/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function options(yargs: CommonYargsArgv) {
describe: "Sets published messages to have no delay",
boolean: true,
}
});
})
.conflicts('delivery-delay', 'no-delivery-delay')
}

function createBody(args: StrictYargsOptionsToInterface<typeof options>): CreateQueueBody {
Expand Down Expand Up @@ -60,6 +61,5 @@ export async function handler(
logger.log(`Created queue ${args.name}.`);
} catch(e) {
handleFetchError(e as {code?: number})
throw e;
}
}

0 comments on commit 77a75c9

Please sign in to comment.