X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/396af2e18eb02d4ec1e35edbc62f01e84bae2b46..e737005f89c7c663e1636830001730ad79396bdc:/schedule_test.go diff --git a/schedule_test.go b/schedule_test.go index 5ef174b..c13f023 100644 --- a/schedule_test.go +++ b/schedule_test.go @@ -245,3 +245,24 @@ func scheduleTestOpen(t *testing.T) (*Schedules, string) { return schedules, path } + +func TestToolboxRunsTheScheduleTools(t *testing.T) { + schedules, _ := scheduleTestOpen(t) + box := &Toolbox{ + schedules: schedules, + } + + require.Equal(t, "Schedule 1 set. Next: Monday 2026-11-09 08:00 -03:00.", box.run(t.Context(), "schedule_set", `{"text":"Tell the user the news.","at":null,"cron":"0 8 * * 1-5"}`)) + require.Equal(t, "Schedule 2 set. Next: Sunday 2026-11-08 20:02 -03:00.", box.run(t.Context(), "schedule_set", `{"text":"Remind the user to drink water.","at":"2026-11-08 20:02","cron":null}`)) + require.Equal(t, "2 | Sunday 2026-11-08 20:02 -03:00 | once | Remind the user to drink water.\n1 | Monday 2026-11-09 08:00 -03:00 | 0 8 * * 1-5 | Tell the user the news.", box.run(t.Context(), "schedule_list", `{}`)) + require.Equal(t, "Schedule 1 removed.", box.run(t.Context(), "schedule_remove", `{"id":1}`)) + require.Equal(t, "error: no schedule 1", box.run(t.Context(), "schedule_remove", `{"id":1}`)) + require.Equal(t, "error: give either at or cron, and null for the other", box.run(t.Context(), "schedule_set", `{"text":"x","at":null,"cron":null}`)) +} + +func TestSubagentHasNoScheduleTools(t *testing.T) { + box := &Toolbox{} + require.Equal(t, `error: unknown tool "schedule_set"`, box.run(t.Context(), "schedule_set", `{"text":"x","at":"2026-11-09 09:00","cron":null}`)) + require.Equal(t, `error: unknown tool "schedule_list"`, box.run(t.Context(), "schedule_list", `{}`)) + require.Equal(t, `error: unknown tool "schedule_remove"`, box.run(t.Context(), "schedule_remove", `{"id":1}`)) +}