跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

job_stop_test.go

36 行 · 920 B历史下载
1package cage
2
3import (
4 "testing"
5 "time"
6)
7
8func TestJobStopCoversLateAndRunningHostagents(t *testing.T) {
9 profile := t.TempDir()
10 id := "0123456789ab"
11 called := make(chan struct{}, 1)
12 stop, err := WatchJobStop(profile, id, func() { called <- struct{}{} })
13 if err != nil {
14 t.Fatal(err)
15 }
16 defer stop()
17 if err = RequestJobStop(profile, id); err != nil {
18 t.Fatal(err)
19 }
20 select {
21 case <-called:
22 case <-time.After(2 * time.Second):
23 t.Fatal("running hostagent did not observe cancellation")
24 }
25 if _, err = WatchJobStop(profile, id, func() { t.Error("late startup callback") }); err == nil {
26 t.Fatal("cancelled job could start a detached hostagent")
27 }
28 fresh, err := WatchJobStop(profile, "abcdef012345", func() { t.Error("new job was cancelled") })
29 if err != nil {
30 t.Fatal(err)
31 }
32 fresh()
33 if err = RequestJobStop(profile, "../../unrelated"); err == nil {
34 t.Fatal("accepted a path as job ID")
35 }
36}