mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-05-25 16:00:35 +00:00
Merge pull request #2938 from hschne/fix/cron-command-action
fix(cron): add missing action arg for command job execution
This commit is contained in:
@@ -320,6 +320,7 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := map[string]any{
|
args := map[string]any{
|
||||||
|
"action": "run",
|
||||||
"command": job.Payload.Command,
|
"command": job.Payload.Command,
|
||||||
"__channel": channel,
|
"__channel": channel,
|
||||||
"__chat_id": chatID,
|
"__chat_id": chatID,
|
||||||
|
|||||||
@@ -329,6 +329,31 @@ func TestCronTool_ExecuteJobSkipsWhenMessageToolAlreadySent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCronTool_ExecuteJobRunsCommand(t *testing.T) {
|
||||||
|
tool := newTestCronToolWithConfig(t, config.DefaultConfig())
|
||||||
|
job := &cron.CronJob{}
|
||||||
|
job.Payload.Channel = "cli"
|
||||||
|
job.Payload.To = "direct"
|
||||||
|
job.Payload.Command = "echo cron-test-ok"
|
||||||
|
|
||||||
|
if got := tool.ExecuteJob(context.Background(), job); got != "ok" {
|
||||||
|
t.Fatalf("ExecuteJob() = %q, want ok", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
var msg bus.OutboundMessage
|
||||||
|
select {
|
||||||
|
case msg = <-tool.msgBus.OutboundChan():
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("timeout waiting for outbound message")
|
||||||
|
}
|
||||||
|
if !strings.Contains(msg.Content, "cron-test-ok") {
|
||||||
|
t.Fatalf("expected command output containing 'cron-test-ok', got: %s", msg.Content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCronTool_ExecuteJobReturnsErrorWithoutPublish(t *testing.T) {
|
func TestCronTool_ExecuteJobReturnsErrorWithoutPublish(t *testing.T) {
|
||||||
executor := &stubJobExecutor{
|
executor := &stubJobExecutor{
|
||||||
response: "this response must not be published",
|
response: "this response must not be published",
|
||||||
|
|||||||
Reference in New Issue
Block a user