跳到主要内容

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

浏览文件

defaults_unix_test.go

75 行 · 1.5 KB历史下载
1//go:build !windows
2
3// SPDX-FileCopyrightText: Copyright The Lima Authors
4// SPDX-License-Identifier: Apache-2.0
5
6package limayaml
7
8import (
9 "os"
10 "path/filepath"
11 "testing"
12
13 "gotest.tools/v3/assert"
14)
15
16func TestExtractTimezoneFromPath(t *testing.T) {
17 tmpDir := t.TempDir()
18
19 // Create test timezone directory structure
20 assert.NilError(t, os.MkdirAll(filepath.Join(tmpDir, "Etc"), 0o755))
21 assert.NilError(t, os.WriteFile(filepath.Join(tmpDir, "Etc", "UTC"), []byte{}, 0o644))
22 assert.NilError(t, os.WriteFile(filepath.Join(tmpDir, "UTC"), []byte{}, 0o644))
23 assert.NilError(t, os.MkdirAll(filepath.Join(tmpDir, "Antarctica"), 0o755))
24 assert.NilError(t, os.WriteFile(filepath.Join(tmpDir, "Antarctica", "Troll"), []byte{}, 0o644))
25
26 tests := []struct {
27 name string
28 path string
29 want string
30 wantErr bool
31 }{
32 {
33 "valid_timezone",
34 filepath.Join(tmpDir, "Antarctica", "Troll"),
35 "Antarctica/Troll",
36 false,
37 },
38 {
39 "root_level_zone",
40 filepath.Join(tmpDir, "UTC"),
41 "UTC",
42 false,
43 },
44 {
45 "outside_zoneinfo",
46 "/tmp/somefile",
47 "",
48 true,
49 },
50 {
51 "empty_path",
52 "",
53 "",
54 true,
55 },
56 {
57 "nonexistent_file",
58 filepath.Join(tmpDir, "Invalid", "Zone"),
59 "",
60 true,
61 },
62 }
63
64 for _, tt := range tests {
65 t.Run(tt.name, func(t *testing.T) {
66 got, err := extractTZFromPath(tt.path)
67 if tt.wantErr {
68 assert.Assert(t, err != nil, "expected error but got none")
69 } else {
70 assert.NilError(t, err)
71 }
72 assert.Equal(t, tt.want, got)
73 })
74 }
75}