refactor(schema): drop cli shim packages, add testseam swap, consolidate ForTest helpers
- import 统一:删除 cli/contractfinal 与 cli/runtimeannotate 垫片包, 26 个消费文件一律直引 corecmd/*;cli 根仅保留 runtime_schema_seam.go 包内别名,依赖图保持单向无环 - 新增 internal/testseam.Swap[T]:包级 var 注入缝置换由 t.Cleanup 结构性恢复;迁移 pipeline*/stdinIsTerminalFn/loadReviewedCommandRegistry/ schemaCommandCatalogError/schemaParameterBindingData/finalSchemaAgentMetadata 六组核心缝(26+ 处) - ForTest 辅助归拢到 per-package fortest.go(corecmd/contract、 corecmd/contractfinal、shortcut、cli),生产文件只留真逻辑 - 文档同步:runtime_schema_seam.go / runtimeannotate/doc.go 注释、 CHANGELOG、RFC §278-279、AGENTS.md
This commit is contained in:
1 parent
7257919a49
commit
ea43db1d64
47 files changed
+351
-359
No files matched your search
@@ -12,8 +12,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/cli"
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/cli/contractfinal"
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/corecmd/contract"
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/corecmd/contractfinal"
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/testseam"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -337,60 +338,52 @@ func TestCrossPlatformCoverageMetadataSourceAndPathEdges(t *testing.T) {
|
||||
if _, _, _, err := GenerateFromCommandRoot(".", nil, Options{}); err == nil || !strings.Contains(err.Error(), "schema source root is nil") {
|
||||
t.Fatalf("GenerateFromCommandRoot nil root = %v", err)
|
||||
}
|
||||
prevBuild := pipelineBuildEffectiveRegistry
|
||||
prevBind := pipelineBindEffectiveRegistry
|
||||
prevGenerate := pipelineGenerateMetadata
|
||||
t.Cleanup(func() {
|
||||
pipelineBuildEffectiveRegistry = prevBuild
|
||||
pipelineBindEffectiveRegistry = prevBind
|
||||
pipelineGenerateMetadata = prevGenerate
|
||||
})
|
||||
pipelineBuildEffectiveRegistry = func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
testseam.Swap(t, &pipelineBuildEffectiveRegistry, func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
return cli.EffectiveCommandRegistry{}, nil
|
||||
}
|
||||
pipelineBindEffectiveRegistry = func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
})
|
||||
testseam.Swap(t, &pipelineBindEffectiveRegistry, func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
return cli.BoundCommandRegistry{}, nil
|
||||
}
|
||||
pipelineGenerateMetadata = func(Options) (File, Stats, error) {
|
||||
})
|
||||
testseam.Swap(t, &pipelineGenerateMetadata, func(Options) (File, Stats, error) {
|
||||
return File{}, Stats{}, nil
|
||||
}
|
||||
})
|
||||
if _, _, _, err := GenerateFromCommandRoot(" ", &cobra.Command{Use: "dws"}, Options{}); err != nil {
|
||||
t.Fatalf("GenerateFromCommandRoot empty rootPath defaults: %v", err)
|
||||
}
|
||||
pipelineBuildEffectiveRegistry = func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
testseam.Swap(t, &pipelineBuildEffectiveRegistry, func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
return cli.EffectiveCommandRegistry{}, errors.New("build boom")
|
||||
}
|
||||
})
|
||||
if _, _, _, err := GenerateFromCommandRoot(".", &cobra.Command{Use: "dws"}, Options{}); err == nil || !strings.Contains(err.Error(), "build effective") {
|
||||
t.Fatalf("build error = %v", err)
|
||||
}
|
||||
pipelineBuildEffectiveRegistry = func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
testseam.Swap(t, &pipelineBuildEffectiveRegistry, func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
return cli.EffectiveCommandRegistry{}, nil
|
||||
}
|
||||
pipelineBindEffectiveRegistry = func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
})
|
||||
testseam.Swap(t, &pipelineBindEffectiveRegistry, func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
return cli.BoundCommandRegistry{}, errors.New("bind boom")
|
||||
}
|
||||
})
|
||||
if _, _, _, err := GenerateFromCommandRoot(".", &cobra.Command{Use: "dws"}, Options{}); err == nil || !strings.Contains(err.Error(), "bind effective") {
|
||||
t.Fatalf("bind error = %v", err)
|
||||
}
|
||||
pipelineBindEffectiveRegistry = func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
testseam.Swap(t, &pipelineBindEffectiveRegistry, func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
return cli.BoundCommandRegistry{}, nil
|
||||
}
|
||||
pipelineGenerateMetadata = func(Options) (File, Stats, error) {
|
||||
})
|
||||
testseam.Swap(t, &pipelineGenerateMetadata, func(Options) (File, Stats, error) {
|
||||
return File{}, Stats{}, errors.New("generate boom")
|
||||
}
|
||||
})
|
||||
if _, _, _, err := GenerateFromCommandRoot(".", &cobra.Command{Use: "dws"}, Options{}); err == nil || !strings.Contains(err.Error(), "generate in-memory") {
|
||||
t.Fatalf("generate error = %v", err)
|
||||
}
|
||||
pipelineBuildEffectiveRegistry = func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
testseam.Swap(t, &pipelineBuildEffectiveRegistry, func(*cobra.Command) (cli.EffectiveCommandRegistry, error) {
|
||||
return cli.EffectiveCommandRegistry{Commands: []cli.CommandSpec{{
|
||||
CanonicalPath: "coverage.missing",
|
||||
PrimaryCLIPath: "coverage missing",
|
||||
Visibility: cli.SchemaVisibilityPublic,
|
||||
}}}, nil
|
||||
}
|
||||
pipelineBindEffectiveRegistry = func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
})
|
||||
testseam.Swap(t, &pipelineBindEffectiveRegistry, func(*cobra.Command, cli.EffectiveCommandRegistry) (cli.BoundCommandRegistry, error) {
|
||||
return cli.BoundCommandRegistry{}, nil
|
||||
}
|
||||
})
|
||||
if _, _, _, err := GenerateFromCommandRoot(".", &cobra.Command{Use: "dws"}, Options{}); err == nil || !strings.Contains(err.Error(), "selection coverage incomplete") {
|
||||
t.Fatalf("selection coverage error = %v", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user