refactor: 移除顶层 defaults 配置段,简化为 target 显式字段 > 代码内置默认值
- 移除 DefaultsConfig 类型、ProbeConfig.defaults 字段 - 移除 CheckerSchemas.defaults、ResolveContext.defaults、CheckerValidationInput.defaults - 更新所有 checker schema/resolve/validate 删除 defaults 合并逻辑 - 更新 config-loader 不再读取传递 defaults - 更新测试、README、DEVELOPMENT、probes.example.yaml - 重新生成 probe-config.schema.json(不含 defaults) - 同步 delta specs 到主规范 - 归档 openspec change
This commit is contained in:
@@ -4,13 +4,12 @@ import { validateDbConfig } from "../../../../../src/server/checker/runner/db/va
|
||||
|
||||
describe("validateDbConfig", () => {
|
||||
test("空配置无问题", () => {
|
||||
const result = validateDbConfig({ defaults: {}, targets: [] });
|
||||
const result = validateDbConfig({ targets: [] });
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("缺少 db.url 返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ id: "test", name: "test", type: "db" }],
|
||||
});
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
@@ -21,7 +20,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("db.url 为空字符串返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ db: { url: "" }, id: "test", name: "test", type: "db" }],
|
||||
});
|
||||
const urlError = result.find((e) => e.path.includes("db.url"));
|
||||
@@ -31,7 +29,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("db.query 为空字符串返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ db: { query: "", url: "sqlite://:memory:" }, id: "test", name: "test", type: "db" }],
|
||||
});
|
||||
const queryError = result.find((e) => e.path.includes("db.query"));
|
||||
@@ -41,7 +38,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("db 分组未知字段返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ db: { timeout: 5, url: "sqlite://:memory:" }, id: "test", name: "test", type: "db" }],
|
||||
});
|
||||
const unknownError = result.find((e) => e.path.includes("db.timeout"));
|
||||
@@ -51,7 +47,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect.durationMs 数组简写返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{
|
||||
db: { url: "sqlite://:memory:" },
|
||||
@@ -69,7 +64,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect.rowCount 非法 operator 返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{ db: { url: "sqlite://:memory:" }, expect: { rowCount: { foo: 1 } }, id: "test", name: "test", type: "db" },
|
||||
],
|
||||
@@ -81,7 +75,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect.rows 不是数组返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{ db: { url: "sqlite://:memory:" }, expect: { rows: "not-array" }, id: "test", name: "test", type: "db" },
|
||||
],
|
||||
@@ -93,7 +86,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect.rows 元素不是对象返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{ db: { url: "sqlite://:memory:" }, expect: { rows: ["not-object"] }, id: "test", name: "test", type: "db" },
|
||||
],
|
||||
@@ -105,7 +97,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect.rows 中 regex 正则非法返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{
|
||||
db: { url: "sqlite://:memory:" },
|
||||
@@ -123,7 +114,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("expect 未知字段返回错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ db: { url: "sqlite://:memory:" }, expect: { status: [200] }, id: "test", name: "test", type: "db" }],
|
||||
});
|
||||
const unknownError = result.find((e) => e.path.includes("expect.status"));
|
||||
@@ -133,7 +123,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("有效配置无错误", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{
|
||||
db: { query: "SELECT 1", url: "sqlite://:memory:" },
|
||||
@@ -149,7 +138,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("忽略非 db 类型 target", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [{ id: "test", name: "test", type: "http" }],
|
||||
});
|
||||
expect(result).toHaveLength(0);
|
||||
@@ -157,7 +145,6 @@ describe("validateDbConfig", () => {
|
||||
|
||||
test("多个 db target 分别校验", () => {
|
||||
const result = validateDbConfig({
|
||||
defaults: {},
|
||||
targets: [
|
||||
{ db: { url: "sqlite://:memory:" }, id: "db1", name: "db1", type: "db" },
|
||||
{ db: { url: "" }, id: "db2", name: "db2", type: "db" },
|
||||
|
||||
Reference in New Issue
Block a user