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

fix: no events without proxy env vars #849

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 18 additions & 12 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,24 @@ export class Diagnostics {
const httpsProxyEnvVarStatus = getStatus(httpsProxyEnvVars);
const noProxyEnvVarStatus = getStatus(noProxyEnvVars);

await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'http_proxy and HTTP_proxy environment variables match',
status: httpProxyEnvVarStatus,
});
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'https_proxy and HTTPS_PROXY environment variables match',
status: httpsProxyEnvVarStatus,
});
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'no_proxy and NO_PROXY environment variables match',
status: noProxyEnvVarStatus,
});
if (httpProxyEnvVars.length) {
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'http_proxy and HTTP_PROXY environment variables match',
status: httpProxyEnvVarStatus,
});
}
if (httpsProxyEnvVars.length) {
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'https_proxy and HTTPS_PROXY environment variables match',
status: httpsProxyEnvVarStatus,
});
}
if (noProxyEnvVars.length) {
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'no_proxy and NO_PROXY environment variables match',
status: noProxyEnvVarStatus,
});
}

if (httpProxyEnvVarStatus === 'fail') {
this.doctor.addSuggestion(messages.getMessage('matchProxyEnvVarSuggestion', ['http_proxy', 'HTTP_PROXY']));
Expand Down
2 changes: 1 addition & 1 deletion test/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Diagnostics', () => {
const diagnostics = new Diagnostics(dr, oclifConfig);
await diagnostics.proxyEnvVarsCheck();

expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 3 times').to.equal(3);
expect(lifecycleEmitSpy.callCount, 'Expected no "Doctor:diagnostic" event fired').to.equal(0);
expect(drAddSuggestionSpy.called, 'Expected no suggestions to be added').to.be.false;
});

Expand Down