mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-18 03:37:33 +08:00
refactor: stabilize runtime and unify config
This commit is contained in:
@@ -37,3 +37,27 @@ func TestRemindTool_UsesToolContextForDeliveryTarget(t *testing.T) {
|
||||
t.Fatalf("expected to chat-123, got %q", jobs[0].Payload.To)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemindTool_ParsesStringTargets(t *testing.T) {
|
||||
storePath := filepath.Join(t.TempDir(), "jobs.json")
|
||||
cs := cron.NewCronService(storePath, nil)
|
||||
tool := NewRemindTool(cs)
|
||||
|
||||
_, err := tool.Execute(context.Background(), map[string]interface{}{
|
||||
"message": "call mom",
|
||||
"time_expr": "10m",
|
||||
"channel": "telegram",
|
||||
"chat_id": "chat-456",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Execute returned error: %v", err)
|
||||
}
|
||||
|
||||
jobs := cs.ListJobs(true)
|
||||
if len(jobs) != 1 {
|
||||
t.Fatalf("expected 1 job, got %d", len(jobs))
|
||||
}
|
||||
if jobs[0].Payload.Channel != "telegram" || jobs[0].Payload.To != "chat-456" {
|
||||
t.Fatalf("unexpected delivery target: %+v", jobs[0].Payload)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user