跳到主要内容

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

浏览文件

validate_test.go

74 行 · 1.9 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4// From https://github.com/containerd/containerd/blob/v2.1.1/pkg/identifiers/validate_test.go
5// SPDX-FileCopyrightText: Copyright The containerd Authors
6// LICENSE: https://github.com/containerd/containerd/blob/v2.1.1/LICENSE
7// NOTICE: https://github.com/containerd/containerd/blob/v2.1.1/NOTICE
8
9/*
10 Copyright The containerd Authors.
11
12 Licensed under the Apache License, Version 2.0 (the "License");
13 you may not use this file except in compliance with the License.
14 You may obtain a copy of the License at
15
16 http://www.apache.org/licenses/LICENSE-2.0
17
18 Unless required by applicable law or agreed to in writing, software
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
23*/
24
25package identifiers
26
27import (
28 "strings"
29 "testing"
30
31 "gotest.tools/v3/assert"
32)
33
34func TestValidIdentifiers(t *testing.T) {
35 for _, input := range []string{
36 "default",
37 "Default",
38 t.Name(),
39 "default-default",
40 "containerd.io",
41 "foo.boo",
42 "swarmkit.docker.io",
43 "0912341234",
44 "task.0.0123456789",
45 "container.system-75-f19a.00",
46 "underscores_are_allowed",
47 strings.Repeat("a", maxLength),
48 } {
49 t.Run(input, func(t *testing.T) {
50 assert.NilError(t, Validate(input))
51 })
52 }
53}
54
55func TestInvalidIdentifiers(t *testing.T) {
56 for _, input := range []string{
57 "",
58 ".foo..foo",
59 "foo/foo",
60 "foo/..",
61 "foo..foo",
62 "foo.-boo",
63 "-foo.boo",
64 "foo.boo-",
65 "but__only_tasteful_underscores",
66 "zn--e9.org", // or something like it!
67 "default--default",
68 strings.Repeat("a", maxLength+1),
69 } {
70 t.Run(input, func(t *testing.T) {
71 assert.ErrorContains(t, Validate(input), "")
72 })
73 }
74}