-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
> syncBinary 目前会通过定时任务单机每天创建,导致多实例冲突 > 其他任务类型均通过事件触发不受影响 * 创建 syncBinary 任务时,手动去重 * 添加 bizId 参数 进行兜底
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert = require('assert'); | ||
import { app } from 'egg-mock/bootstrap'; | ||
import { Context } from 'egg'; | ||
import { BinarySyncerService } from 'app/core/service/BinarySyncerService'; | ||
|
||
describe('test/core/service/BinarySyncerService/createTask.test.ts', () => { | ||
let ctx: Context; | ||
let binarySyncerService: BinarySyncerService; | ||
|
||
beforeEach(async () => { | ||
ctx = await app.mockModuleContext(); | ||
binarySyncerService = await ctx.getEggObject(BinarySyncerService); | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.destroyModuleContext(ctx); | ||
}); | ||
|
||
describe('createTask()', () => { | ||
it('should ignore duplicate binary task', async () => { | ||
const task = await binarySyncerService.createTask('banana', {}); | ||
const newTask = await binarySyncerService.createTask('banana', {}); | ||
assert(task?.taskId === newTask?.taskId); | ||
assert(task?.bizId === 'SyncBinary:banana'); | ||
}); | ||
}); | ||
}); |