wrapper-validation-action/__tests__/checksums.test.ts

33 lines
907 B
TypeScript
Raw Normal View History

import * as checksums from '../src/checksums'
2021-05-14 08:35:46 +00:00
import nock from 'nock'
2022-10-24 16:16:09 +00:00
import {afterEach, describe, expect, test, jest} from '@jest/globals'
jest.setTimeout(30000)
test('fetches wrapper jars checksums', async () => {
const validChecksums = await checksums.fetchValidChecksums(false)
expect(validChecksums.length).toBeGreaterThan(10)
})
2021-05-14 08:35:46 +00:00
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()
})
})
})