跳到主要内容

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

浏览文件

waiting_test.go

42 行 · 1.2 KB历史下载
1package appupdate
2
3import (
4 "bytes"
5 "encoding/json"
6 "os"
7 "path/filepath"
8 "testing"
9
10 "github.com/sylvinus/agent-vm/internal/cage"
11 "github.com/sylvinus/agent-vm/internal/diagnostics"
12)
13
14func TestUpdateCheckWaitsForProxyButDownloadReportsFailure(t *testing.T) {
15 for _, operation := range []string{"check", "download"} {
16 t.Run(operation, func(t *testing.T) {
17 profile := t.TempDir()
18 config := filepath.Join(profile, "config.json")
19 data, _ := json.Marshal(cage.DefaultConfig())
20 if err := os.WriteFile(config, data, 0600); err != nil {
21 t.Fatal(err)
22 }
23 var output bytes.Buffer
24 code := Run(config, []string{operation}, &output)
25 var state State
26 if err := json.Unmarshal(output.Bytes(), &state); err != nil {
27 t.Fatal(err)
28 }
29 if operation == "check" {
30 if code != 0 || state.Phase != "waiting" || !state.Retryable {
31 t.Fatalf("expected deferred check: code=%d %+v", code, state)
32 }
33 info, err := diagnostics.New(profile).Info()
34 if err != nil || info.Bytes != 0 {
35 t.Fatalf("ordinary wait logged as failure: %+v %v", info, err)
36 }
37 } else if code == 0 || state.Phase != "failed" {
38 t.Fatalf("requested download must report unavailable proxy: code=%d %+v", code, state)
39 }
40 })
41 }
42}