mirror of
https://github.com/certd/certd.git
synced 2026-07-17 11:37:32 +08:00
fix(pipeline-service): 修复流水线运行时超过套餐部署次数仍然能够正常运行的bug
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
import assert from "assert";
|
||||||
|
import { PipelineEntity } from "../entity/pipeline.js";
|
||||||
|
import { PipelineService } from "./pipeline-service.js";
|
||||||
|
|
||||||
|
describe("PipelineService", () => {
|
||||||
|
it("does not start a pipeline run when beforeCheck fails", async () => {
|
||||||
|
const service = new PipelineService();
|
||||||
|
let historyStarted = false;
|
||||||
|
|
||||||
|
service.beforeCheck = async () => {
|
||||||
|
throw new Error("部署次数不足");
|
||||||
|
};
|
||||||
|
service.userService = {
|
||||||
|
async isAdmin() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
service.historyService = {
|
||||||
|
async start() {
|
||||||
|
historyStarted = true;
|
||||||
|
throw new Error("history should not start");
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const entity = new PipelineEntity();
|
||||||
|
entity.id = 1;
|
||||||
|
entity.userId = 1;
|
||||||
|
entity.projectId = 0;
|
||||||
|
entity.content = JSON.stringify({
|
||||||
|
stages: [{ id: "stage1", tasks: [] }],
|
||||||
|
triggers: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
await service.doRun(entity, null, "ALL");
|
||||||
|
|
||||||
|
assert.equal(historyStarted, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -659,6 +659,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
|||||||
suite = res.suite
|
suite = res.suite
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`流水线${entity.id}触发失败(${triggerId}):${e.message}`);
|
logger.error(`流水线${entity.id}触发失败(${triggerId}):${e.message}`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = entity.id;
|
const id = entity.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user