-
-
Notifications
You must be signed in to change notification settings - Fork 987
test: add scanner update rate override for testing #3241
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { mock } from 'node:test'; | ||
|
|
||
| export async function runWithMockTimers<T>( | ||
| runPromise: Promise<T>, | ||
| tickMs = 4000 | ||
| ): Promise<T> { | ||
|
Comment on lines
+3
to
+6
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Takes an already-invoked Promise instead of a factory. Its fine as it is for now since |
||
| mock.timers.enable({ apis: ['setTimeout'] }); | ||
| try { | ||
| let settled = false; | ||
| runPromise | ||
| .catch(() => undefined) | ||
| .finally(() => { | ||
| settled = true; | ||
| }); | ||
| let guard = 0; | ||
| while (!settled && guard++ < 100000) { | ||
| await new Promise((resolve) => setImmediate(resolve)); | ||
| mock.timers.tick(tickMs); | ||
| } | ||
| return await runPromise; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
michaelhthomas marked this conversation as resolved.
Outdated
|
||
| } finally { | ||
| mock.timers.reset(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonarr was being imported before the
getTvShowmock which caused it to not work. Moved it here so the mock actually applies.