Keep registry key validation local to workflowdef with composition-root injection, adapt FlatCatalog for projectworkflow, and drive the orchestrator through LiveInstancePort views instead of projectinstance.
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package workflowdef_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/workflowdef"
|
|
)
|
|
|
|
func TestValidateDefinition_RejectsEmptyStages(t *testing.T) {
|
|
res := workflowdef.ValidateDefinition(workflowdef.VersionDefinition{}, nil, nil, nil, nil)
|
|
if res.Valid {
|
|
t.Fatal("expected invalid for empty stages")
|
|
}
|
|
}
|
|
|
|
func TestValidateDefinition_AcceptsMinimalWorkflow(t *testing.T) {
|
|
def := workflowdef.VersionDefinition{
|
|
SchemaVersion: 1,
|
|
Stages: []workflowdef.StageDef{{
|
|
Key: "s1", Name: "阶段1", Position: 0,
|
|
DocTasks: []workflowdef.DocTaskDef{{
|
|
Key: "t1", Title: "任务1", DefaultEnabled: true,
|
|
OutputDocType: "doc1", OutputDocTitle: "文档1",
|
|
}},
|
|
}},
|
|
}
|
|
res := workflowdef.ValidateDefinition(def, func(string, int) bool { return true }, nil, nil, nil)
|
|
if !res.Valid {
|
|
t.Fatalf("expected valid, got issues: %+v", res.Issues)
|
|
}
|
|
}
|
|
|
|
func TestValidateDefinition_RejectsMissingTemplate(t *testing.T) {
|
|
def := workflowdef.VersionDefinition{
|
|
Stages: []workflowdef.StageDef{{
|
|
Key: "s1", Position: 0,
|
|
DocTasks: []workflowdef.DocTaskDef{{
|
|
Key: "t1", DefaultEnabled: true, TemplateAssetKey: "missing",
|
|
OutputDocType: "d", OutputDocTitle: "D",
|
|
}},
|
|
}},
|
|
}
|
|
res := workflowdef.ValidateDefinition(def, func(string, int) bool { return false }, nil, nil, nil)
|
|
if res.Valid {
|
|
t.Fatal("expected invalid when template not ready")
|
|
}
|
|
}
|