Skip to content

Commit

Permalink
[Storage][Queue] Rename the queue message operation result types
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremymeng committed Oct 19, 2019
1 parent d1708c0 commit 1160194
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 57 deletions.
22 changes: 12 additions & 10 deletions sdk/storage/storage-queue/src/QueueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export interface QueueClearMessagesOptions extends CommonOptions {
}

/**
* Options to configure Messages - Enqueue operation
* Options to configure Messages - Send operation
*
* @export
* @interface QueueSendMessageOptions
Expand Down Expand Up @@ -236,12 +236,12 @@ export interface QueuePeekMessagesOptions

export declare type QueueSendMessageResponse = {
/**
* @member {string} messageId The ID of the enqueued Message.
* @member {string} messageId The ID of the sent Message.
*/
messageId: string;
/**
* @member {string} popReceipt This value is required to delete the Message.
* If deletion fails using this popreceipt then the message has been dequeued
* If deletion fails using this popreceipt then the message has been received
* by another client.
*/
popReceipt: string;
Expand Down Expand Up @@ -280,8 +280,10 @@ export declare type QueueSendMessageResponse = {
};
};

export declare type ReceivedMessageItem = Models.DequeuedMessageItem;

export declare type QueueReceiveMessageResponse = {
dequeuedMessageItems: Models.DequeuedMessageItem[];
receivedMessageItems: ReceivedMessageItem[];
} & Models.MessagesDequeueHeaders & {
/**
* The underlying HTTP response.
Expand All @@ -298,7 +300,7 @@ export declare type QueueReceiveMessageResponse = {
/**
* The response body as parsed JSON or XML
*/
parsedBody: Models.DequeuedMessageItem[];
parsedBody: ReceivedMessageItem[];
};
};

Expand Down Expand Up @@ -767,7 +769,7 @@ export class QueueClient extends StorageClient {
}

/**
* Enqueue adds a new message to the back of a queue. The visibility timeout specifies how long
* SendMessage adds a new message to the back of a queue. The visibility timeout specifies how long
* the message should be invisible to Dequeue and Peek operations.
* The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding.
* To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
Expand Down Expand Up @@ -843,13 +845,13 @@ export class QueueClient extends StorageClient {
date: response.date,
requestId: response.requestId,
clientRequestId: response.clientRequestId,
dequeuedMessageItems: [],
receivedMessageItems: [],
version: response.version,
errorCode: response.errorCode
};

for (const item of response) {
res.dequeuedMessageItems.push(item);
res.receivedMessageItems.push(item);
}

return res;
Expand Down Expand Up @@ -913,7 +915,7 @@ export class QueueClient extends StorageClient {
* Delete permanently removes the specified message from its queue.
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-message2
*
* @param {string} popReceipt A valid pop receipt value returned from an earlier call to the dequeue messages or update message operation.
* @param {string} popReceipt A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
* @param {QueueDeleteMessageOptions} [options] Options to delete message operation.
* @returns {Promise<QueueDeleteMessageResponse>} Response data for the delete message operation.
* @memberof QueueClient
Expand Down Expand Up @@ -946,7 +948,7 @@ export class QueueClient extends StorageClient {
* To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/update-message
*
* @param {string} popReceipt A valid pop receipt value returned from an earlier call to the dequeue messages or update message operation.
* @param {string} popReceipt A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
* @param {string} message Message to update.
* @param {number} visibilityTimeout Specifies the new visibility timeout value, in seconds,
* relative to server time. The new value must be larger than or equal to 0,
Expand Down
72 changes: 36 additions & 36 deletions sdk/storage/storage-queue/test/messagesclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ describe("MessagesClient", () => {
assert.ok(dqResult.requestId);
assert.ok(eResult.clientRequestId);
assert.ok(dqResult.version);
assert.deepStrictEqual(dqResult.dequeuedMessageItems.length, 1);
assert.ok(dqResult.dequeuedMessageItems[0].popReceipt);
assert.deepStrictEqual(dqResult.dequeuedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dqResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dqResult.receivedMessageItems.length, 1);
assert.ok(dqResult.receivedMessageItems[0].popReceipt);
assert.deepStrictEqual(dqResult.receivedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dqResult.receivedMessageItems[0].messageId, eResult.messageId);

let cResult = await queueClient.clearMessages();
assert.ok(cResult.date);
Expand Down Expand Up @@ -122,14 +122,14 @@ describe("MessagesClient", () => {
assert.ok(dResult.date);
assert.ok(dResult.requestId);
assert.ok(dResult.version);
assert.deepStrictEqual(dResult.dequeuedMessageItems.length, 2);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.dequeuedMessageItems[0].popReceipt);
assert.ok(dResult.dequeuedMessageItems[0].nextVisibleOn);
assert.deepStrictEqual(dResult.receivedMessageItems.length, 2);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.receivedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.receivedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.receivedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.receivedMessageItems[0].popReceipt);
assert.ok(dResult.receivedMessageItems[0].nextVisibleOn);

assert.deepStrictEqual(pResult.peekedMessageItems[1].messageText, messageContent);

Expand Down Expand Up @@ -171,14 +171,14 @@ describe("MessagesClient", () => {
assert.ok(dResult.date);
assert.ok(dResult.requestId);
assert.ok(dResult.version);
assert.deepStrictEqual(dResult.dequeuedMessageItems.length, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, "");
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.dequeuedMessageItems[0].popReceipt);
assert.ok(dResult.dequeuedMessageItems[0].nextVisibleOn);
assert.deepStrictEqual(dResult.receivedMessageItems.length, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, "");
assert.deepStrictEqual(dResult.receivedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.receivedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.receivedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.receivedMessageItems[0].popReceipt);
assert.ok(dResult.receivedMessageItems[0].nextVisibleOn);
});

it("enqueue, peek, dequeue special characters", async () => {
Expand Down Expand Up @@ -216,14 +216,14 @@ describe("MessagesClient", () => {
assert.ok(dResult.date);
assert.ok(dResult.requestId);
assert.ok(dResult.version);
assert.deepStrictEqual(dResult.dequeuedMessageItems.length, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, specialMessage);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.dequeuedMessageItems[0].popReceipt);
assert.ok(dResult.dequeuedMessageItems[0].nextVisibleOn);
assert.deepStrictEqual(dResult.receivedMessageItems.length, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, specialMessage);
assert.deepStrictEqual(dResult.receivedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.receivedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.receivedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.receivedMessageItems[0].popReceipt);
assert.ok(dResult.receivedMessageItems[0].nextVisibleOn);
});

it("enqueue, peek, dequeue with 64KB characters size which is computed after encoding", async () => {
Expand Down Expand Up @@ -260,14 +260,14 @@ describe("MessagesClient", () => {
assert.ok(dResult.date);
assert.ok(dResult.requestId);
assert.ok(dResult.version);
assert.deepStrictEqual(dResult.dequeuedMessageItems.length, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.dequeuedMessageItems[0].popReceipt);
assert.ok(dResult.dequeuedMessageItems[0].nextVisibleOn);
assert.deepStrictEqual(dResult.receivedMessageItems.length, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.receivedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.receivedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.receivedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.receivedMessageItems[0].popReceipt);
assert.ok(dResult.receivedMessageItems[0].nextVisibleOn);
});

it("enqueue, peek and dequeue negative", async () => {
Expand Down
16 changes: 8 additions & 8 deletions sdk/storage/storage-queue/test/node/messagesclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ describe("MessagesClient Node.js only", () => {
assert.ok(dResult.requestId);
assert.ok(eResult.clientRequestId);
assert.ok(dResult.version);
assert.deepStrictEqual(dResult.dequeuedMessageItems.length, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.dequeuedMessageItems[0].popReceipt);
assert.ok(dResult.dequeuedMessageItems[0].nextVisibleOn);
assert.deepStrictEqual(dResult.receivedMessageItems.length, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.receivedMessageItems[0].dequeueCount, 1);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageId, eResult.messageId);
assert.deepStrictEqual(dResult.receivedMessageItems[0].insertedOn, eResult.insertedOn);
assert.deepStrictEqual(dResult.receivedMessageItems[0].expiresOn, eResult.expiresOn);
assert.ok(dResult.receivedMessageItems[0].popReceipt);
assert.ok(dResult.receivedMessageItems[0].nextVisibleOn);
});

it("enqueue negative with 65537B(64KB+1B) characters including special char which is computed after encoding", async () => {
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/storage-queue/test/node/sas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
const dResult = await messagesClientwithSAS.receiveMessages({
visibilityTimeout: 1
});
assert.deepStrictEqual(dResult.dequeuedMessageItems[0].messageText, messageContent);
assert.deepStrictEqual(dResult.receivedMessageItems[0].messageText, messageContent);

await delay(2 * 1000);

const sasURLForMessage = `${queueClient.url}?${queueSAS}`;
const messageIdClientwithSAS = new QueueClient(sasURLForMessage);
const deleteResult = await messageIdClientwithSAS.deleteMessage(
dResult.dequeuedMessageItems[0].messageId,
dResult.dequeuedMessageItems[0].popReceipt
dResult.receivedMessageItems[0].messageId,
dResult.receivedMessageItems[0].popReceipt
);
assert.ok(deleteResult.requestId);
assert.ok(deleteResult.clientRequestId);
Expand Down

0 comments on commit 1160194

Please sign in to comment.