1
0
Fork 0
mirror of https://github.com/actions/toolkit.git synced 2025-06-11 10:18:16 +09:00

revert octokit changes

This commit is contained in:
Tatyana Kostromskaya 2023-09-26 11:05:37 +00:00
parent 6d37c6eb2b
commit ddc9c52eb6
5 changed files with 328 additions and 410 deletions

View file

@ -1,13 +1,13 @@
import * as http from 'http'
import * as https from 'https'
import { createProxy } from 'proxy'
import proxy from 'proxy'
// Default values are set when the module is imported, so we need to set proxy first.
const proxyUrl = 'http://127.0.0.1:8081'
const originalProxyUrl = process.env['https_proxy']
process.env['https_proxy'] = proxyUrl
// eslint-disable-next-line import/first
import { getOctokit } from '../src/github'
import {getOctokit} from '../src/github'
describe('@actions/github', () => {
let proxyConnects: string[]
@ -16,13 +16,12 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = createProxy()
await new Promise<void>(resolve => {
proxyServer = proxy()
await new Promise(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve())
})
proxyServer.on('connect', req => {
console.log('connect', req.url)
proxyConnects.push(req.url ?? '')
})
})
@ -33,7 +32,7 @@ describe('@actions/github', () => {
afterAll(async () => {
// Stop proxy server
await new Promise<void>(resolve => {
await new Promise(resolve => {
proxyServer.once('close', () => resolve())
proxyServer.close()
})
@ -70,7 +69,7 @@ describe('@actions/github', () => {
const repository = await octokit.graphql(
'{repository(owner:"actions", name:"toolkit"){name}}'
)
expect(repository).toEqual({ repository: { name: 'toolkit' } })
expect(repository).toEqual({repository: {name: 'toolkit'}})
expect(proxyConnects).toEqual(['api.github.com:443'])
})

View file

@ -1,5 +1,5 @@
import * as http from 'http'
import { createProxy } from 'proxy'
import proxy from 'proxy'
import {getOctokit} from '../src/github'
import {GitHub, getOctokitOptions} from '../src/utils'
@ -12,7 +12,7 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = createProxy()
proxyServer = proxy()
await new Promise(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve(null))

View file

@ -1,4 +1,4 @@
declare module 'proxy1' {
declare module 'proxy' {
import * as http from 'http'
function internal(): http.Server
export = internal