跳到主要内容

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

浏览文件

hostagent_test.go

35 行 · 1.4 KB历史下载
1package limaembed
2
3import (
4 "os"
5 "strings"
6 "testing"
7)
8
9// The copy of limactl's hostagent command differs from it only as its
10// header says: after a Lima upgrade, copy it again.
11func TestHostagentCopy(t *testing.T) {
12 upstream, err := os.ReadFile("../../third_party/lima/cmd/limactl/hostagent.go")
13 if err != nil {
14 t.Fatal(err)
15 }
16 ours, err := os.ReadFile("hostagent.go")
17 if err != nil {
18 t.Fatal(err)
19 }
20 want := strings.Replace(string(upstream), "package main", "package limaembed", 1)
21 want = strings.Replace(want, "WrapArgsError(cobra.ExactArgs(1))", "cobra.ExactArgs(1)", 1)
22 want = strings.Replace(want, "signalCh := make(chan os.Signal, 1)", "signalCh := hostagentSignals", 1)
23 want = strings.Replace(want, "signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)", "signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)\n\tstopNotification, err := watchHostagentStop(socket)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer stopNotification()", 1)
24 // Our header: the comment block after the license lines.
25 got := string(ours)
26 start := strings.Index(got, "// Copied from")
27 end := strings.Index(got, "package limaembed")
28 if start < 0 || end < start {
29 t.Fatal("hostagent.go lost its header")
30 }
31 got = got[:start] + got[end:]
32 if got != want {
33 t.Error("hostagent.go differs from third_party/lima/cmd/limactl/hostagent.go beyond its header: copy it again")
34 }
35}