Make queue private and one-line initiatialization for it
This commit is contained in:
@@ -33,7 +33,7 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
private readonly variantAnalyses = new Map<number, VariantAnalysis>();
|
||||
private readonly views = new Map<number, VariantAnalysisView>();
|
||||
private static readonly maxConcurrentDownloads = 3;
|
||||
public queue: PQueue;
|
||||
private readonly queue = new PQueue({ concurrency: VariantAnalysisManager.maxConcurrentDownloads });
|
||||
|
||||
constructor(
|
||||
private readonly ctx: ExtensionContext,
|
||||
@@ -47,8 +47,6 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
|
||||
this.variantAnalysisResultsManager = this.push(new VariantAnalysisResultsManager(cliServer, storagePath, logger));
|
||||
this.variantAnalysisResultsManager.onResultLoaded(this.onRepoResultLoaded.bind(this));
|
||||
|
||||
this.queue = new PQueue({ concurrency: VariantAnalysisManager.maxConcurrentDownloads });
|
||||
}
|
||||
|
||||
public async showView(variantAnalysisId: number): Promise<void> {
|
||||
@@ -176,6 +174,10 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
});
|
||||
}
|
||||
|
||||
public downloadsQueueSize(): number {
|
||||
return this.queue.pending;
|
||||
}
|
||||
|
||||
public async promptOpenVariantAnalysis() {
|
||||
const credentials = await Credentials.initialize(this.ctx);
|
||||
if (!credentials) { throw Error('Error authenticating with GitHub'); }
|
||||
|
||||
@@ -157,7 +157,7 @@ describe('Variant Analysis Manager', async function() {
|
||||
await variantAnalysisManager.enqueueDownload(scannedRepos[1], variantAnalysis, cancellationTokenSource.token);
|
||||
await variantAnalysisManager.enqueueDownload(scannedRepos[2], variantAnalysis, cancellationTokenSource.token);
|
||||
|
||||
expect(variantAnalysisManager.queue.pending).to.equal(0);
|
||||
expect(variantAnalysisManager.downloadsQueueSize()).to.equal(0);
|
||||
expect(getResultsSpy).to.have.been.calledThrice;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user