This commit is contained in:
lpf
2026-02-17 00:14:12 +08:00
parent ff3ae92acd
commit e5a3ea6863
3 changed files with 93 additions and 40 deletions

View File

@@ -3,6 +3,8 @@ package agent
import (
"testing"
"time"
"clawgo/pkg/bus"
)
func TestParseTaskExecutionDirectives_RunCommand(t *testing.T) {
@@ -152,3 +154,36 @@ func TestExtractJSONObject_Invalid(t *testing.T) {
t.Fatalf("expected empty json, got: %q", raw)
}
}
func TestShouldHandleControlIntents_UserMessage(t *testing.T) {
msg := bus.InboundMessage{
SenderID: "user",
Content: "请进入自主模式",
}
if !shouldHandleControlIntents(msg) {
t.Fatalf("expected user message to be control-eligible")
}
}
func TestShouldHandleControlIntents_AutonomySyntheticSender(t *testing.T) {
msg := bus.InboundMessage{
SenderID: "autonomy",
Content: "自主模式第 1 轮推进",
}
if shouldHandleControlIntents(msg) {
t.Fatalf("expected autonomy synthetic message to be ignored for control intents")
}
}
func TestShouldHandleControlIntents_AutoLearnSyntheticMetadata(t *testing.T) {
msg := bus.InboundMessage{
SenderID: "gateway",
Content: "自动学习第 1 轮",
Metadata: map[string]string{
"source": "autolearn",
},
}
if shouldHandleControlIntents(msg) {
t.Fatalf("expected autolearn synthetic metadata message to be ignored for control intents")
}
}