Skip to content

Commit

Permalink
Improve test (#237890)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Jan 14, 2025
1 parent ef520e4 commit 384b832
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions extensions/vscode-api-tests/src/singlefolder-tests/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,27 @@ import { middleware, Straightforward } from 'straightforward';
await proxyListen;
const proxyPort = (sf.server.address() as AddressInfo).port;

await vscode.workspace.getConfiguration().update('integration-test.http.proxy', `PROXY 127.0.0.1:${proxyPort}`, vscode.ConfigurationTarget.Global);
await delay(1000); // Wait for the configuration change to propagate.
await new Promise<void>((resolve, reject) => {
https.get(url, res => {
if (res.statusCode === 418) {
resolve();
} else {
reject(new Error(`Unexpected status code (expected 418): ${res.statusCode}`));
for (let i = 0; i < 3; i++) {
await vscode.workspace.getConfiguration().update('integration-test.http.proxy', `PROXY 127.0.0.1:${proxyPort}`, vscode.ConfigurationTarget.Global);
await delay(1000); // Wait for the configuration change to propagate.
try {
await new Promise<void>((resolve, reject) => {
https.get(url, res => {
if (res.statusCode === 418) {
resolve();
} else {
reject(new Error(`Unexpected status code (expected 418): ${res.statusCode}`));
}
})
.on('error', reject);
});
break; // Exit the loop if the request is successful
} catch (err) {
if (i === 2) {
throw err; // Rethrow the error if it's the last attempt
}
})
.on('error', reject);
});
}
}

authEnabled = true;
await new Promise<void>((resolve, reject) => {
Expand Down

0 comments on commit 384b832

Please sign in to comment.