Skip to content

Commit

Permalink
Merge branch 'master' into nor1
Browse files Browse the repository at this point in the history
  • Loading branch information
fhinkel committed Feb 25, 2020
2 parents ecdf51d + 89f5f29 commit 0e9eee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions functions/background/index.js
Expand Up @@ -15,7 +15,7 @@
'use strict';

// [START functions_background_promise]
const requestPromiseNative = require('request-promise-native');
const {request} = require('gaxios');

/**
* Background Cloud Function that returns a Promise. Note that we don't pass
Expand All @@ -26,8 +26,8 @@ const requestPromiseNative = require('request-promise-native');
* @returns {Promise}
*/
exports.helloPromise = data => {
return requestPromiseNative({
uri: data.endpoint,
return request({
url: data.endpoint,
});
};
// [END functions_background_promise]
11 changes: 2 additions & 9 deletions functions/background/package.json
@@ -1,6 +1,5 @@
{
"name": "nodejs-docs-samples-functions-background",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
Expand All @@ -15,17 +14,11 @@
"test": "mocha test/*.test.js --timeout=20000"
},
"dependencies": {
"request": "^2.88.0",
"request-promise-native": "^1.0.5"
"gaxios": "^2.3.1"
},
"devDependencies": {
"@google-cloud/functions-framework": "^1.1.1",
"child-process-promise": "^2.2.1",
"mocha": "^7.0.0",
"requestretry": "^4.0.0"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true
"mocha": "^7.0.0"
}
}
16 changes: 9 additions & 7 deletions functions/background/test/index.test.js
Expand Up @@ -15,7 +15,7 @@
'use strict';

const assert = require('assert');
const requestRetry = require('requestretry');
const {request} = require('gaxios');
const execPromise = require('child-process-promise').exec;
const path = require('path');

Expand Down Expand Up @@ -52,14 +52,16 @@ it('should make a promise request', async () => {
},
};

const response = await requestRetry({
const response = await request({
url: `${BASE_URL}/`,
method: 'POST',
body: event,
retryDelay: 200,
json: true,
data: event,
responseType: 'text',
retryConfig: {
httpMethodsToRetry: ['POST'],
},
});

assert.strictEqual(response.statusCode, 200);
assert.ok(response.body.includes(`Example Domain`));
assert.strictEqual(response.status, 200);
assert.ok(response.data.includes(`Example Domain`));
});

0 comments on commit 0e9eee4

Please sign in to comment.