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:
Mauro
2026-05-24 22:07:18 +02:00
committed by GitHub
2 changed files with 26 additions and 0 deletions
+1
View File
@@ -320,6 +320,7 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string {
}
args := map[string]any{
"action": "run",
"command": job.Payload.Command,
"__channel": channel,
"__chat_id": chatID,
+25
View File
@@ -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) {
executor := &stubJobExecutor{
response: "this response must not be published",