mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Disable one test and add a new utility function (#7486)
Skip problematic tests
This commit is contained in:
@@ -54,6 +54,23 @@ export async function connectToServer(server: TestServerProfile, timeout: number
|
||||
return result.connectionId;
|
||||
}
|
||||
|
||||
export class PromiseCancelledError extends Error { }
|
||||
/**
|
||||
* Wait for a promise to resolve but timeout after a certain amount of time.
|
||||
* It will throw CancelledError when it fails.
|
||||
* @param p promise to wait on
|
||||
* @param timeout time to wait
|
||||
*/
|
||||
export async function asyncTimeout<T>(p: Thenable<T>, timeout: number): Promise<(T | undefined)> {
|
||||
const timeoutPromise = new Promise<T>((done, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(new PromiseCancelledError('Promise did not resolve in time'));
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
return Promise.race([p, timeoutPromise]);
|
||||
}
|
||||
|
||||
export async function pollTimeout(predicate: () => Thenable<boolean>, intervalDelay: number, timeoutTime: number): Promise<boolean> {
|
||||
let interval: NodeJS.Timer;
|
||||
return new Promise(pollOver => {
|
||||
|
||||
Reference in New Issue
Block a user