feat: 新增 target description 字段,收紧 id/name 长度,调整延迟列和名称列
This commit is contained in:
@@ -29,6 +29,7 @@ function targetId(store: ProbeStore, name: string): string {
|
||||
}
|
||||
|
||||
const httpTarget: ResolvedHttpTarget = {
|
||||
description: null,
|
||||
expect: { maxDurationMs: 3000, status: [200] },
|
||||
group: "default",
|
||||
http: {
|
||||
@@ -54,6 +55,7 @@ const commandTarget: ResolvedCommandTarget = {
|
||||
exec: "ping",
|
||||
maxOutputBytes: 104857600,
|
||||
},
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "test-cmd",
|
||||
intervalMs: 60000,
|
||||
@@ -364,6 +366,7 @@ describe("ProbeStore", () => {
|
||||
test("删除 target 级联删除 check_results", () => {
|
||||
const cascadeStore = new ProbeStore(join(tempDir, "cascade.db"));
|
||||
const cascadeTarget: ResolvedHttpTarget = {
|
||||
description: null,
|
||||
group: "default",
|
||||
http: {
|
||||
headers: {},
|
||||
@@ -427,6 +430,7 @@ describe("ProbeStore", () => {
|
||||
const freshStore = new ProbeStore(join(tempDir, "fresh-map.db"));
|
||||
freshStore.syncTargets([
|
||||
{
|
||||
description: null,
|
||||
group: "default",
|
||||
http: {
|
||||
headers: {},
|
||||
@@ -474,6 +478,7 @@ describe("ProbeStore", () => {
|
||||
const freshStore = new ProbeStore(join(tempDir, "fresh-stats.db"));
|
||||
freshStore.syncTargets([
|
||||
{
|
||||
description: null,
|
||||
group: "default",
|
||||
http: {
|
||||
headers: {},
|
||||
@@ -662,4 +667,35 @@ describe("ProbeStore", () => {
|
||||
|
||||
pruneStore.close();
|
||||
});
|
||||
|
||||
test("syncTargets 持久化 description", () => {
|
||||
const descStore = new ProbeStore(join(tempDir, "desc.db"));
|
||||
const targetWithDesc: ResolvedHttpTarget = {
|
||||
...httpTarget,
|
||||
description: "检查 API 健康状态",
|
||||
id: "desc-test",
|
||||
name: "desc-test",
|
||||
};
|
||||
descStore.syncTargets([targetWithDesc]);
|
||||
const t = descStore.getTargets()[0]!;
|
||||
expect(t.description).toBe("检查 API 健康状态");
|
||||
descStore.close();
|
||||
});
|
||||
|
||||
test("未配置 description 时持久化为 null", () => {
|
||||
const noDescStore = new ProbeStore(join(tempDir, "no-desc.db"));
|
||||
noDescStore.syncTargets([{ ...httpTarget, description: null, id: "no-desc", name: "no-desc" }]);
|
||||
const t = noDescStore.getTargets()[0]!;
|
||||
expect(t.description).toBeNull();
|
||||
noDescStore.close();
|
||||
});
|
||||
|
||||
test("同步更新 description", () => {
|
||||
const updateDescStore = new ProbeStore(join(tempDir, "update-desc.db"));
|
||||
updateDescStore.syncTargets([{ ...httpTarget, description: "旧描述", id: "update-desc", name: "update-desc" }]);
|
||||
updateDescStore.syncTargets([{ ...httpTarget, description: "新描述", id: "update-desc", name: "update-desc" }]);
|
||||
const t = updateDescStore.getTargets()[0]!;
|
||||
expect(t.description).toBe("新描述");
|
||||
updateDescStore.close();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user