跳到主要内容

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

浏览文件

resources_test.go

40 行 · 1.3 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package hostagent
5
6import (
7 "context"
8 "runtime"
9 "slices"
10 "testing"
11
12 "github.com/lima-vm/sshocker/pkg/ssh"
13)
14
15func TestResourceProbeCommand(t *testing.T) {
16 agent := HostAgent{
17 sshLocalPort: 60022, instSSHAddress: "127.0.0.1",
18 sshConfig: &ssh.SSHConfig{AdditionalArgs: []string{
19 "-o", "IdentityFile=private-instance-key", "-o", "ControlMaster=auto",
20 "-o", "ControlPath=instance/ssh.sock", "-o", "ControlPersist=5m",
21 }},
22 }
23 configured := slices.Clone(agent.sshConfig.Args())
24 const probe = "cat /proc/meminfo"
25 cmd := agent.resourceProbeCommand(context.Background(), probe)
26 want := slices.Clone(configured)
27 if runtime.GOOS == "windows" {
28 want = []string{
29 "-o", "ControlMaster=no", "-o", "ControlPath=none", "-o", "ControlPersist=no",
30 "-o", "IdentityFile=private-instance-key",
31 }
32 }
33 want = append(want, "-o", "ConnectTimeout=2", "-o", "ClearAllForwardings=yes", "-T", "-p", "60022", "127.0.0.1", "--", probe)
34 if !slices.Equal(cmd.Args[1:], want) {
35 t.Fatalf("probe arguments: got %q, want %q", cmd.Args[1:], want)
36 }
37 if !slices.Equal(configured, agent.sshConfig.Args()) {
38 t.Fatal("resource probe changed the SSH configuration used by other host-agent tasks")
39 }
40}