it('should make a promise request', async () => { const event = { data: { endpoint: 'https://example.com', }, }; const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', body: event, retryDelay: 200, json: true, }); assert.strictEqual(response.statusCode, 200); assert.ok(response.body.includes(`Example Domain`)); });
it('should shut down GCE instances when budget is exceeded', async () => { const ffProc = execPromise( `functions-framework --target=limitUse --signature-type=event`, {timeout: 1000, shell: true, cwd} ); const jsonData = {costAmount: 500, budgetAmount: 400}; const encodedData = Buffer.from(JSON.stringify(jsonData)).toString('base64'); const pubsubMessage = {data: encodedData, attributes: {}}; const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', body: {data: pubsubMessage}, retryDelay: 200, json: true, }); // Wait for the functions framework to stop // Must be BEFORE assertions, in case they fail await ffProc; console.log(response.body); assert.strictEqual(response.statusCode, 200); assert.ok(response.body.includes('instance(s) stopped successfully')); });
const response = await requestRetry({ body: { deviceID: '', const response = await requestRetry({ contextValue, });
const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST',
const ffProc = startFF(PORT); await requestRetry({ url: `http://localhost:${PORT}/blurOffensiveImages`, body: { const ffProc = startFF(PORT); await requestRetry({ url: `http://localhost:${PORT}/blurOffensiveImages`, body: {
const pubsubMessage = {data: encodedData, attributes: {}}; const response = await requestRetry({ url: `${BASE_URL}/notifySlack`, method: 'POST', const pubsubMessage = {data: encodedData, attributes: {}}; const response = await requestRetry({ url: `${BASE_URL}/stopBilling`, method: 'POST',
const response = await requestRetry({ method: 'POST', url: `${BASE_URL}/del`, const response = await requestRetry({ method: 'POST', url: `${BASE_URL}/del`,
const response = await requestRetry({ url: `${BASE_URL}/get`, method: 'POST', const response = await requestRetry({ method: 'POST', url: `${BASE_URL}/get`,
const response = await requestRetry({ url: `${BASE_URL}/set`, method: 'POST',
it('should make a promise request', async () => { const event = { data: { endpoint: 'https://example.com', }, }; const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', body: event, retryDelay: 200, json: true, }); assert.strictEqual(response.statusCode, 200); assert.ok(response.body.includes(`Example Domain`)); });
it('should shut down GCE instances when budget is exceeded', async () => { const ffProc = execPromise( `functions-framework --target=limitUse --signature-type=event`, {timeout: 1000, shell: true, cwd} ); const jsonData = {costAmount: 500, budgetAmount: 400}; const encodedData = Buffer.from(JSON.stringify(jsonData)).toString('base64'); const pubsubMessage = {data: encodedData, attributes: {}}; const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', body: {data: pubsubMessage}, retryDelay: 200, json: true, }); // Wait for the functions framework to stop // Must be BEFORE assertions, in case they fail await ffProc; console.log(response.body); assert.strictEqual(response.statusCode, 200); assert.ok(response.body.includes('instance(s) stopped successfully')); });
const response = await requestRetry({ body: { deviceID: '', const response = await requestRetry({ contextValue, });
const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST', const response = await requestRetry({ url: `${BASE_URL}/`, method: 'POST',
const ffProc = startFF(PORT); await requestRetry({ url: `http://localhost:${PORT}/blurOffensiveImages`, body: { const ffProc = startFF(PORT); await requestRetry({ url: `http://localhost:${PORT}/blurOffensiveImages`, body: {
const response = await requestRetry({ url: `${BASE_URL}/set`, method: 'POST',