Skip to content

Commit

Permalink
fix: no events without proxy env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Aug 27, 2024
1 parent 9057e12 commit 3b9abc6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
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

0 comments on commit 3b9abc6

Please sign in to comment.