migrate github badges to use got instead of request; affects [github librariesio] (#7212)

* migrate github badges to use got instead of request

* simplify creation of requestFetcher in libraries.io base

* improve libraries.io connection error test

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
chris48s
2021-10-31 16:19:09 +00:00
committed by GitHub
parent 8fcde9de85
commit eb07b60cf0
10 changed files with 137 additions and 198 deletions

View File

@@ -1,7 +1,8 @@
import { expect } from 'chai'
import config from 'config'
import request from 'request'
import { fetchFactory } from '../../core/base-service/got.js'
import GithubApiProvider from './github-api-provider.js'
const requestFetcher = fetchFactory()
describe('Github API provider', function () {
const baseUrl = process.env.GITHUB_URL || 'https://api.github.com'
@@ -30,8 +31,8 @@ describe('Github API provider', function () {
it('should be able to run 10 requests', async function () {
this.timeout('20s')
for (let i = 0; i < 10; ++i) {
await githubApiProvider.requestAsPromise(
request,
await githubApiProvider.fetch(
requestFetcher,
'/repos/rust-lang/rust',
{}
)
@@ -52,8 +53,8 @@ describe('Github API provider', function () {
const headers = []
async function performOneRequest() {
const { res } = await githubApiProvider.requestAsPromise(
request,
const { res } = await githubApiProvider.fetch(
requestFetcher,
'/repos/rust-lang/rust',
{}
)