Files
Agent-System/internal/workflowdef/validator_test.go
T
weichenandCursor edffe74009 feat(db): add workflow definitions, versions, and template asset tables
Introduce Phase 2 IAM-adjacent schema for versioned workflow definitions,
template assets/versions, and workflow_defs permissions seed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 02:50:22 +00:00

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)
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)
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)
if res.Valid {
t.Fatal("expected invalid when template not ready")
}
}