跳到主要内容

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

浏览文件

protect.bats

68 行 · 2.2 KB历史下载
1# SPDX-FileCopyrightText: Copyright The Lima Authors
2# SPDX-License-Identifier: Apache-2.0
3
4load "../helpers/load"
5
6INSTANCE=bats-dummy
7CLONE=clone
8NOTEXIST=notexist
9
10local_setup_file() {
11 local inst
12 for inst in "$CLONE" "$NOTEXIST"; do
13 limactl unprotect "$inst" || :
14 limactl delete --force "$inst" || :
15 done
16}
17
18@test 'protecting a non-existing instance fails' {
19 run_e -1 limactl protect "${NOTEXIST}"
20 assert_fatal "failed to inspect instance \`${NOTEXIST}\`…"
21}
22
23@test 'protecting the dummy instance succeeds' {
24 run_e -0 limactl protect "$INSTANCE"
25 assert_info "Protected \`${INSTANCE}\`"
26 assert_file_exists "${LIMA_HOME}/${INSTANCE}/protected"
27}
28
29@test 'protecting it again shows a warning, but succeeds' {
30 run_e -0 limactl protect "$INSTANCE"
31 assert_warning "Instance \`${INSTANCE}\` is already protected. Skipping."
32 assert_file_exists "${LIMA_HOME}/${INSTANCE}/protected"
33}
34
35@test 'cloning a protected instance creates an unprotected clone' {
36 run_e -0 limactl clone --yes "$INSTANCE" "$CLONE"
37 # TODO there is currently no output from the clone command, which feels wrong
38 refute_output
39 assert_file_not_exists "${LIMA_HOME}/${CLONE}/protected"
40}
41
42@test 'deleting the unprotected clone instance succeeds' {
43 run_e -0 limactl delete --force "$CLONE"
44 assert_info "Deleted \`${CLONE}\`…"
45}
46
47@test 'deleting protected dummy instance fails' {
48 run_e -1 limactl delete --force "$INSTANCE"
49 assert_fatal "failed to delete instance \`${INSTANCE}\`: instance is protected…"
50 assert_file_exists "$LIMA_HOME/$INSTANCE/protected"
51}
52
53@test 'unprotecting the dummy instance succeeds' {
54 run_e -0 limactl unprotect "$INSTANCE"
55 assert_info "Unprotected \`${INSTANCE}\`"
56 assert_file_not_exists "$LIMA_HOME/$INSTANCE/protected"
57}
58
59@test 'unprotecting it again shows a warning, but succeeds' {
60 run_e -0 limactl unprotect "$INSTANCE"
61 assert_warning "Instance \`${INSTANCE}\` isn't protected. Skipping."
62 assert_file_not_exists "$LIMA_HOME/$INSTANCE/protected"
63}
64
65@test 'deleting unprotected dummy instance succeeds' {
66 run_e -0 limactl delete --force "$INSTANCE"
67 assert_info "Deleted \`${INSTANCE}\`…"
68}