test(agent): provide schedule tool context
- commit
- 3d78ab0857b8429ae05e94f2dc7eafe5ba862728
- author
- brice · · 2026-08-15 15:44 UTC
- parent
- 8d00c1b
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +4 -2
M packages/agent/tools/schedule_test.go +4 -2
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | package tools | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | + | "context" | |
| 4 | 5 | "encoding/json" | |
| 5 | 6 | "testing" | |
| 6 | 7 | "time" | |
| @@ -19,7 +20,8 @@ func TestScheduleToolScopesTasksToCurrentSession(t *testing.T) { | |||
| 19 | 20 | Location: func() *time.Location { return time.UTC }, | |
| 20 | 21 | } | |
| 21 | 22 | ||
| 22 | - | result, err := tool.Execute(nil, json.RawMessage(`{"action":"add","cron":"@hourly","message":"check build"}`), nil) | |
| 23 | + | ctx := context.Background() | |
| 24 | + | result, err := tool.Execute(ctx, json.RawMessage(`{"action":"add","cron":"@hourly","message":"check build"}`), nil) | |
| 23 | 25 | if err != nil || result.IsError { | |
| 24 | 26 | t.Fatalf("Execute(add) = %#v, %v", result, err) | |
| 25 | 27 | } | |
| @@ -31,7 +33,7 @@ func TestScheduleToolScopesTasksToCurrentSession(t *testing.T) { | |||
| 31 | 33 | if err != nil { | |
| 32 | 34 | t.Fatalf("Engine.Add() error = %v", err) | |
| 33 | 35 | } | |
| 34 | - | result, err = tool.Execute(nil, json.RawMessage(`{"action":"cancel","id":"`+otherSession.ID+`"}`), nil) | |
| 36 | + | result, err = tool.Execute(ctx, json.RawMessage(`{"action":"cancel","id":"`+otherSession.ID+`"}`), nil) | |
| 35 | 37 | if err != nil || !result.IsError { | |
| 36 | 38 | t.Fatalf("Execute(cancel other session) = %#v, %v; want scoped error", result, err) | |
| 37 | 39 | } | |
| @@ -1,6 +1,7 @@ | |||||
| 1 | package tools | 1 | package tools | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | + | "context" | |||
| 4 | "encoding/json" | 5 | "encoding/json" | ||
| 5 | "testing" | 6 | "testing" | ||
| 6 | "time" | 7 | "time" | ||
| @@ -19,7 +20,8 @@ func TestScheduleToolScopesTasksToCurrentSession(t *testing.T) { | |||||
| 19 | Location: func() *time.Location { return time.UTC }, | 20 | Location: func() *time.Location { return time.UTC }, | ||
| 20 | } | 21 | } | ||
| 21 | 22 | ||||
| 22 | - | result, err := tool.Execute(nil, json.RawMessage(`{"action":"add","cron":"@hourly","message":"check build"}`), nil) | 23 | + | ctx := context.Background() |
| 24 | + | result, err := tool.Execute(ctx, json.RawMessage(`{"action":"add","cron":"@hourly","message":"check build"}`), nil) | |||
| 23 | if err != nil || result.IsError { | 25 | if err != nil || result.IsError { | ||
| 24 | t.Fatalf("Execute(add) = %#v, %v", result, err) | 26 | t.Fatalf("Execute(add) = %#v, %v", result, err) | ||
| 25 | } | 27 | } | ||
| @@ -31,7 +33,7 @@ func TestScheduleToolScopesTasksToCurrentSession(t *testing.T) { | |||||
| 31 | if err != nil { | 33 | if err != nil { | ||
| 32 | t.Fatalf("Engine.Add() error = %v", err) | 34 | t.Fatalf("Engine.Add() error = %v", err) | ||
| 33 | } | 35 | } | ||
| 34 | - | result, err = tool.Execute(nil, json.RawMessage(`{"action":"cancel","id":"`+otherSession.ID+`"}`), nil) | 36 | + | result, err = tool.Execute(ctx, json.RawMessage(`{"action":"cancel","id":"`+otherSession.ID+`"}`), nil) |
| 35 | if err != nil || !result.IsError { | 37 | if err != nil || !result.IsError { | ||
| 36 | t.Fatalf("Execute(cancel other session) = %#v, %v; want scoped error", result, err) | 38 | t.Fatalf("Execute(cancel other session) = %#v, %v; want scoped error", result, err) | ||
| 37 | } | 39 | } | ||