chore: add initial tests

This commit is contained in:
Tom Keller
2022-10-15 20:25:56 -07:00
parent 933beb7f7c
commit a61ce85bf3
8 changed files with 923 additions and 535 deletions
+9 -1
View File
@@ -38,9 +38,17 @@ export function isDefined<T>(i: T | undefined | null): i is T {
return i !== undefined && i !== null;
}
function sleep(ms: number) {
function defaultSleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
let sleep = defaultSleep;
export function withsleep(s: typeof sleep) {
sleep = s;
}
export function reset() {
sleep = defaultSleep;
}
// retryAndBackoff retries with exponential backoff the promise if the error isRetryable upto maxRetries time.
export async function retryAndBackoff<T>(