跳到主要内容

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

浏览文件

share_test.go

47 行 · 1.3 KB历史下载
1package limaembed
2
3import (
4 "os"
5 "testing"
6 "testing/fstest"
7)
8
9func TestGuestAgentMatchesGuestAndCurrentBuild(t *testing.T) {
10 linuxArch := guestArch()
11 const darwinFile = "assets/Darwin/lima-guestagent.Darwin-aarch64.gz"
12 files := fstest.MapFS{
13 "assets/lima-guestagent.Linux-" + linuxArch + ".gz": {Data: []byte("linux")},
14 darwinFile: {Data: []byte("darwin")},
15 }
16 dir := t.TempDir()
17 share, err := writeShare(dir, files)
18 if err != nil {
19 t.Fatal(err)
20 }
21 for _, guest := range []struct{ os, arch, data string }{
22 {"Linux", linuxArch, "linux"},
23 {"Darwin", "aarch64", "darwin"},
24 } {
25 path, err := share.GuestAgent(guest.os, guest.arch)
26 if err != nil {
27 t.Fatal(err)
28 }
29 data, err := os.ReadFile(path)
30 if err != nil || string(data) != guest.data {
31 t.Fatalf("%s/%s: read %q, %v", guest.os, guest.arch, data, err)
32 }
33 }
34 if path, err := share.GuestAgent("Darwin", "x86_64"); err == nil {
35 t.Fatalf("used %s for an unbundled architecture", path)
36 }
37
38 // A different build can reuse the same profile with the old file on disk.
39 delete(files, darwinFile)
40 share, err = writeShare(dir, files)
41 if err != nil {
42 t.Fatal(err)
43 }
44 if path, err := share.GuestAgent("Darwin", "aarch64"); err == nil {
45 t.Fatalf("used %s after the build stopped bundling it", path)
46 }
47}