跳到主要内容

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

浏览文件

store_test.go

63 行 · 1.2 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package store
5
6import (
7 "testing"
8
9 "gotest.tools/v3/assert"
10
11 "github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
12)
13
14func TestValidateInstName(t *testing.T) {
15 instNames := []string{
16 "default",
17 "Ubuntu-20.04",
18 "example.com",
19 "under_score",
20 "1-2_3.4",
21 "yml",
22 "yaml",
23 "foo.yaml.com",
24 }
25 for _, arg := range instNames {
26 t.Run(arg, func(t *testing.T) {
27 err := dirnames.ValidateInstName(arg)
28 assert.NilError(t, err)
29 })
30 }
31 invalidIdentifiers := []string{
32 "",
33 "my/instance",
34 "my\\instance",
35 "c:default",
36 "dot.",
37 ".dot",
38 "dot..dot",
39 "underscore_",
40 "_underscore",
41 "underscore__underscore",
42 "dash-",
43 "-dash",
44 "dash--dash",
45 }
46 for _, arg := range invalidIdentifiers {
47 t.Run(arg, func(t *testing.T) {
48 err := dirnames.ValidateInstName(arg)
49 assert.ErrorContains(t, err, "not a valid identifier")
50 })
51 }
52 yamlNames := []string{
53 "default.yaml",
54 "MY.YAML",
55 "My.YmL",
56 }
57 for _, arg := range yamlNames {
58 t.Run(arg, func(t *testing.T) {
59 err := dirnames.ValidateInstName(arg)
60 assert.ErrorContains(t, err, "must not end with .y")
61 })
62 }
63}