diff --git a/__tests__/checksums.test.ts b/__tests__/checksums.test.ts index aa27208..471c33b 100644 --- a/__tests__/checksums.test.ts +++ b/__tests__/checksums.test.ts @@ -1,6 +1,29 @@ import * as checksums from '../src/checksums' +import nock from 'nock' test('fetches wrapper jars checksums', async () => { const validChecksums = await checksums.fetchValidChecksums(false) expect(validChecksums.length).toBeGreaterThan(10) }) + +describe('retry', () => { + afterEach(() => { + nock.cleanAll() + }) + + describe('for /versions/all API', () => { + test('retry three times', async () => { + nock('https://services.gradle.org', {allowUnmocked: true}) + .get('/versions/all') + .times(3) + .replyWithError({ + message: 'connect ECONNREFUSED 104.18.191.9:443', + code: 'ECONNREFUSED' + }) + + const validChecksums = await checksums.fetchValidChecksums(false) + expect(validChecksums.length).toBeGreaterThan(10) + nock.isDone() + }) + }) +}) diff --git a/package-lock.json b/package-lock.json index 388539f..6f46952 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3136,7 +3136,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", - "dev": true + "dev": true, + "optional": true }, "har-schema": { "version": "2.0.0", @@ -3594,6 +3595,7 @@ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", "dev": true, + "optional": true, "requires": { "is-docker": "^2.0.0" } @@ -5338,6 +5340,12 @@ "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", "dev": true }, + "lodash.set": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", + "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=", + "dev": true + }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -5516,6 +5524,18 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "nock": { + "version": "13.0.11", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.0.11.tgz", + "integrity": "sha512-sKZltNkkWblkqqPAsjYW0bm3s9DcHRPiMOyKO/PkfJ+ANHZ2+LA2PLe22r4lLrKgXaiSaDQwW3qGsJFtIpQIeQ==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash.set": "^4.3.2", + "propagate": "^2.0.0" + } + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -5533,6 +5553,7 @@ "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz", "integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==", "dev": true, + "optional": true, "requires": { "growly": "^1.3.0", "is-wsl": "^2.2.0", @@ -5923,6 +5944,12 @@ "sisteransi": "^1.0.4" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", @@ -6409,7 +6436,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", - "dev": true + "dev": true, + "optional": true }, "signal-exit": { "version": "3.0.3", @@ -7206,7 +7234,8 @@ "version": "8.3.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", - "dev": true + "dev": true, + "optional": true }, "v8-compile-cache": { "version": "2.1.1", diff --git a/package.json b/package.json index 49edb9a..6dd1ccb 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "jest": "26.4.2", "jest-circus": "26.4.2", "js-yaml": "3.14.0", + "nock": "^13.0.11", "prettier": "2.1.2", "ts-jest": "26.4.0", "typescript": "4.0.3"