From 8f5324ccf98279752b7da249b020ced4102f5f1d Mon Sep 17 00:00:00 2001 From: Dianne Laguerta Date: Tue, 11 Jul 2023 11:45:55 -0700 Subject: [PATCH] Fix and reenable tests around retries/abuse limit (#33) --- action.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.test.js b/action.test.js index 6c7518d..3c6a890 100644 --- a/action.test.js +++ b/action.test.js @@ -114,7 +114,7 @@ describe('action', () => { test('retries transient errors', (done) => { const scope = nock('https://api.github.com') .get('/repos/hashicorp/copywrite/releases/tags/v0.1.3') - .reply(500, 'expected transient error') + .replyWithError(500, 'expected transient error') .get('/repos/hashicorp/copywrite/releases/tags/v0.1.3') .reply(200, mockRelease) .get('/repos/hashicorp/copywrite/releases/assets/3') @@ -135,11 +135,11 @@ describe('action', () => { done() }) }) - // TODO: fix failing tests - test.skip('retries abuse limit errors', (done) => { + + test('retries abuse limit errors', (done) => { const scope = nock('https://api.github.com') .get('/repos/hashicorp/copywrite/releases/tags/v0.1.3') - .reply(403, { + .replyWithError(403, { message: 'You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.', documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#abuse-rate-limits' }) @@ -164,10 +164,10 @@ describe('action', () => { }) }) - test.skip('retries rate limit errors', (done) => { + test('retries rate limit errors', (done) => { const scope = nock('https://api.github.com') .get('/repos/hashicorp/copywrite/releases/tags/v0.1.3') - .reply(429, 'expected rate limit error') + .replyWithError(429, 'expected rate limit error') .get('/repos/hashicorp/copywrite/releases/tags/v0.1.3') .reply(200, mockRelease) .get('/repos/hashicorp/copywrite/releases/assets/3')