Skip to content

Commit

Permalink
update allow optional messageText (#11258)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljian3377 authored Sep 24, 2020
1 parent 2e8784e commit cbcfa5b
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/review/storage-queue.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class QueueClient extends StorageClient {
sendMessage(messageText: string, options?: QueueSendMessageOptions): Promise<QueueSendMessageResponse>;
setAccessPolicy(queueAcl?: SignedIdentifier[], options?: QueueSetAccessPolicyOptions): Promise<QueueSetAccessPolicyResponse>;
setMetadata(metadata?: Metadata, options?: QueueSetMetadataOptions): Promise<QueueSetMetadataResponse>;
updateMessage(messageId: string, popReceipt: string, message: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise<QueueUpdateMessageResponse>;
updateMessage(messageId: string, popReceipt: string, message?: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise<QueueUpdateMessageResponse>;
}

// @public
Expand Down
11 changes: 7 additions & 4 deletions sdk/storage/storage-queue/src/QueueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,18 +1271,21 @@ export class QueueClient extends StorageClient {
public async updateMessage(
messageId: string,
popReceipt: string,
message: string,
message?: string,
visibilityTimeout?: number,
options: QueueUpdateMessageOptions = {}
): Promise<QueueUpdateMessageResponse> {
const { span, spanOptions } = createSpan("QueueClient-updateMessage", options.tracingOptions);
let queueMessage = undefined;
if (message) {
queueMessage = { messageText: message };
}

try {
return await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
abortSignal: options.abortSignal,
spanOptions,
queueMessage: {
messageText: message
}
queueMessage
});
} catch (e) {
span.setStatus({
Expand Down
9 changes: 9 additions & 0 deletions sdk/storage/storage-queue/test/messageidclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,13 @@ describe("QueueClient messageId methods", () => {
);
assert.equal(newClient.name, queueName, "Queue name is not the same as the one provided.");
});

it("update visibility timeout only preserve content", async () => {
const message = "foo";
const enqueueRes = await queueClient.sendMessage(message, { visibilityTimeout: 10 });
await queueClient.updateMessage(enqueueRes.messageId, enqueueRes.popReceipt);
const receiveMessage = (await queueClient.receiveMessages()).receivedMessageItems[0];
assert.equal(enqueueRes.messageId, receiveMessage.messageId);
assert.equal(message, receiveMessage.messageText);
});
});

0 comments on commit cbcfa5b

Please sign in to comment.