Skip to content

Commit

Permalink
code revise
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyuan Wan committed Apr 27, 2016
1 parent 2f7d3e4 commit 1a6bf4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ClientRuntimes/NodeJS/ms-rest-azure/lib/azureServiceClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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'] = '';
Expand Down

0 comments on commit 1a6bf4e

Please sign in to comment.