mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 21:57:29 +08:00
45 lines
995 B
Go
45 lines
995 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestValidateSubagentsAllowsKnownPeers(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cfg := DefaultConfig()
|
|
cfg.Agents.Router.Enabled = true
|
|
cfg.Agents.Router.MainAgentID = "main"
|
|
cfg.Agents.Subagents["main"] = SubagentConfig{
|
|
Enabled: true,
|
|
Type: "router",
|
|
AcceptFrom: []string{"user", "coder"},
|
|
CanTalkTo: []string{"coder"},
|
|
}
|
|
cfg.Agents.Subagents["coder"] = SubagentConfig{
|
|
Enabled: true,
|
|
Type: "worker",
|
|
AcceptFrom: []string{"main"},
|
|
CanTalkTo: []string{"main"},
|
|
Runtime: SubagentRuntimeConfig{
|
|
Proxy: "proxy",
|
|
},
|
|
}
|
|
|
|
if errs := Validate(cfg); len(errs) != 0 {
|
|
t.Fatalf("expected config to be valid, got %v", errs)
|
|
}
|
|
}
|
|
|
|
func TestValidateSubagentsRejectsUnknownPeer(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cfg := DefaultConfig()
|
|
cfg.Agents.Subagents["coder"] = SubagentConfig{
|
|
Enabled: true,
|
|
AcceptFrom: []string{"main"},
|
|
}
|
|
|
|
if errs := Validate(cfg); len(errs) == 0 {
|
|
t.Fatalf("expected validation errors")
|
|
}
|
|
}
|