* For eventually consistent APIs, retry the test after a few seconds, up to 3 times. * @param {function} testFunction the test function to retry. * @returns {function}
(testFunction)
| 28 | * @returns {function} |
| 29 | */ |
| 30 | function eventually(testFunction) { |
| 31 | return async () => { |
| 32 | let delayMs = 2000; |
| 33 | for (let i = 0; i < 2; ++i) { |
| 34 | try { |
| 35 | return await testFunction(); |
| 36 | } catch (e) { |
| 37 | await new Promise(resolve => setTimeout(resolve, delayMs)); |
| 38 | delayMs *= 2; |
| 39 | } |
| 40 | } |
| 41 | return await testFunction(); |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | describe('Talent Solution Jobs API v4 samples', () => { |
| 46 | const projectId = process.env.GCLOUD_PROJECT; |