From 1a6bf4e79d9daa64ecf3fc4d6e9492ab7cc57b44 Mon Sep 17 00:00:00 2001 From: Qinyuan Wan Date: Wed, 27 Apr 2016 10:36:56 -0700 Subject: [PATCH] code revise --- .../NodeJS/ms-rest-azure/lib/azureServiceClient.js | 8 ++++---- .../NodeJS/ms-rest-azure/test/azureServiceClientTests.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/azureServiceClient.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/azureServiceClient.js index fcc09299d1c03..ca4413b85a00b 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/azureServiceClient.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/azureServiceClient.js @@ -64,7 +64,7 @@ util.inherits(AzureServiceClient, msRest.ServiceClient); */ AzureServiceClient.prototype.getPutOrPatchOperationResult = function (resultOfInitialRequest, options, callback) { return this.getLongRunningOperationResult(resultOfInitialRequest, options, callback); -} +}; /** * Poll Azure long running POST or DELETE operations. (Deprecated, new version of the code-gen will generate code to call getLongRunningOperationResult) @@ -74,7 +74,7 @@ AzureServiceClient.prototype.getPutOrPatchOperationResult = function (resultOfIn */ AzureServiceClient.prototype.getPostOrDeleteOperationResult = function (resultOfInitialRequest, options, callback) { return this.getLongRunningOperationResult(resultOfInitialRequest, options, callback); -} +}; /** * Poll Azure long running PUT, PATCH, POST or DELETE operations. @@ -156,8 +156,8 @@ AzureServiceClient.prototype.getLongRunningOperationResult = function (resultOfI //when done function (err) { if (pollingState.status === LroStates.Succeeded) { - if ((pollingState.azureAsyncOperationHeaderLink || !pollingState.resource) - && (initialRequestMethod === 'PUT' || initialRequestMethod === 'PATCH')) { + if ((pollingState.azureAsyncOperationHeaderLink || !pollingState.resource) && + (initialRequestMethod === 'PUT' || initialRequestMethod === 'PATCH')) { self._updateStateFromGetResourceOperation(resourceUrl, pollingState, function(err) { return callback(err, pollingState.getOperationResponse()); }); diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js index 954032749dcfd..8e11e689690b7 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js @@ -92,9 +92,10 @@ describe('AzureServiceClient', function () { describe('Put', function () { resultOfInitialRequest.response.statusCode = 201; + resultOfInitialRequest.request.method = 'PUT'; it('throw on not Lro related status code', function (done) { - client.getPutOrPatchOperationResult({ response: {statusCode: 10000}, request: { url:"http://foo" }}, function (err, result) { + client.getPutOrPatchOperationResult({ response: {statusCode: 10000}, request: { url:"http://foo", method:'PUT' }}, function (err, result) { err.message.should.containEql('Unexpected polling status code from long running operation'); done(); }); @@ -159,6 +160,7 @@ describe('AzureServiceClient', function () { describe('Patch', function () { resultOfInitialRequest.response.statusCode = 202; resultOfInitialRequest.body.properties.provisioningState = LroStates.Succeeded; + resultOfInitialRequest.request.method = 'PATCH'; it('works by polling from location header', function (done) { resultOfInitialRequest.response.headers['azure-asyncoperation'] = '';