-
Notifications
You must be signed in to change notification settings - Fork 219
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
limit parallel bulk export execution #9031
limit parallel bulk export execution #9031
Conversation
|
…arallel-bulk-export-execution
…arallel-bulk-export-execution
let jobManager: PageBulkExportJobManager; | ||
|
||
beforeAll(() => { | ||
vi.spyOn(configManager, 'getConfig').mockReturnValue(3); |
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.
これ雑すぎるね
beforeAll ではなく個別の it block 内ならギリギリ許容だが、beforeAll だと getConfig の別の引数で呼び出しをするテストを追加した時に意図しない動きをするだろう
|
||
describe('addJob', () => { | ||
it('should add the job to jobsInProgress if under the parallelExecLimit', () => { | ||
const job = { _id: 'job1' } as any; |
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.
as any 回避できないかな?
HydratedDocument や HasObjectId を使うなど
catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
expect(destroySpy).toHaveBeenCalledWith(expect.any(Error)); | ||
} |
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.
toThrowError で確認する方が望ましいかと
https://vitest.dev/api/expect.html#tothrowerror
job3: { stream: undefined }, | ||
}; | ||
expect(jobManager.canExecuteNextJob()).toBe(false); | ||
}); |
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.
全ての it について、
// assign
...
// act
...
// assert
...
というコメントを入れた構成にしてください
const job = { _id: 'job1' } as any; | ||
jobManager.addJob(job, { endpoint: '/test/endpoint' }); | ||
expect(jobManager.jobsInProgress[job._id.toString()]).toEqual({ stream: undefined }); | ||
expect(pageBulkExportServiceMock.executePageBulkExportJob).toHaveBeenCalledWith(job, { endpoint: '/test/endpoint' }); |
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.
// assign
と // assert
両方で jobQueue.length を expect する行を入れてください
つまり、act 前後で期待する数になっているかどうかを確かめる
expect(jobManager.jobsInProgress[jobId]).toBeUndefined(); | ||
expect(jobManager.jobsInProgress[nextJob._id.toString()]).toEqual({ stream: undefined }); | ||
expect(pageBulkExportServiceMock.executePageBulkExportJob).toHaveBeenCalledWith(nextJob, undefined); | ||
}); |
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.
// assign
と // assert
両方で jobQueue.length を expect する行を入れてください
つまり、act 前後で期待する数になっているかどうかを確かめる
実装内容
task
https://redmine.weseek.co.jp/issues/152623