Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions server/lib/scanners/baseScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export interface ProcessableSeason {
}

class BaseScanner<T> {
private bundleSize;
private updateRate;
protected bundleSize;
protected updateRate;
protected progress = 0;
protected items: T[] = [];
protected totalSize?: number = 0;
Expand Down Expand Up @@ -792,6 +792,18 @@ class BaseScanner<T> {
get protectedBundleSize(): number {
return this.bundleSize;
}

/**
* Test-only override to reduce scan delay in unit tests.
* Sets updateRate and/or bundleSize for the next run.
*/
public setTestOverrides(opts: {
updateRate?: number;
bundleSize?: number;
}): void {
if (opts.updateRate !== undefined) this.updateRate = opts.updateRate;
if (opts.bundleSize !== undefined) this.bundleSize = opts.bundleSize;
}
Comment thread
0xSysR3ll marked this conversation as resolved.
}

export default BaseScanner;
2 changes: 2 additions & 0 deletions server/lib/scanners/jellyfin/jellyfin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ function configureJellyfinWithLibrary(

describe('Jellyfin Scanner', () => {
beforeEach(async () => {
jellyfinFullScanner.setTestOverrides({ updateRate: 0 });

getLibraryContentsImpl = async () => [];
getItemDataImpl = async () => undefined;
getSeasonsImpl = async () => [];
Expand Down
1 change: 1 addition & 0 deletions server/lib/scanners/radarr/radarr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function fakeRadarrMovie(overrides: Partial<RadarrMovie> = {}): RadarrMovie {

describe('Radarr Scanner', () => {
beforeEach(() => {
radarrScanner.setTestOverrides({ updateRate: 0 });
getMoviesImpl = async () => [];
});

Expand Down
1 change: 1 addition & 0 deletions server/lib/scanners/sonarr/sonarr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ function configureSonarr(overrides: Partial<SonarrSettings>[] = [{}]): void {

describe('Sonarr Scanner', () => {
beforeEach(() => {
sonarrScanner.setTestOverrides({ updateRate: 0 });
getSeriesImpl = async () => [];
getShowByTvdbIdImpl = async () => fakeTmdbShow(1);
getTvShowImpl = async () => fakeTmdbShow(1);
Expand Down
Loading