Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add logging for proxy use #603

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/helpers/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function generateRequestHeadersPOST(
args: UploaderArgs,
): IRequestHeaders {
if (args.upstream !== '') {
info(`Using ${args.upstream} as the proxy for the PUT command`)
const proxyAgent = new HttpsProxyAgent(args.upstream)
return {
url: `${uploadURL}/upload/v4?package=${getPackage(
Expand Down Expand Up @@ -187,6 +188,7 @@ export function generateRequestHeadersPUT(
): IRequestHeaders {

if (args.upstream !== '') {
info(`Using ${args.upstream} as the proxy for the PUT command`)
const proxyAgent = new HttpsProxyAgent(args.upstream)
return {
url: uploadURL,
Expand Down
29 changes: 29 additions & 0 deletions test/helpers/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,32 @@ describe('generateRequestHeadersPUT()', () => {
)
})
})


describe('generateRequestHeadersPOST()', () => {
test('when args.upstream is set, returns a log line', () => {
// Arrange
const args: UploaderArgs = { ...createEmptyArgs() , upstream: "https://codecov.local:3131"}
const spyLog = jest.spyOn(console, "log")

// Act
void generateRequestHeadersPOST("https://unreachable.codecov.local", "not a token", "", "", args)

// Assert
expect(spyLog).toHaveBeenCalledWith(expect.stringContaining(`Using ${args.upstream} as the proxy for the PUT command`))
})
})

describe('generateRequestHeadersPUT()', () => {
test('when args.upstream is set, returns a log line', () => {
// Arrange
const args: UploaderArgs = { ...createEmptyArgs() , upstream: "https://codecov.local:3131"}
const spyLog = jest.spyOn(console, "log")

// Act
void generateRequestHeadersPUT("https://unreachable.codecov.local", "I'm a coverage file", args)

// Assert
expect(spyLog).toHaveBeenCalledWith(expect.stringContaining(`Using ${args.upstream} as the proxy for the PUT command`))
})
})