chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package xdg_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"academy/cli/internal/xdg"
|
||||
)
|
||||
|
||||
func TestPath_HonorsEnv(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Setenv("XDG_CONFIG_HOME", dir)
|
||||
got, err := xdg.Path("XDG_CONFIG_HOME", ".config", "config.yaml")
|
||||
if err != nil {
|
||||
t.Fatalf("Path: %v", err)
|
||||
}
|
||||
want := filepath.Join(dir, "academy", "config.yaml")
|
||||
if got != want {
|
||||
t.Errorf("got %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPath_FallsBackToHome(t *testing.T) {
|
||||
t.Setenv("XDG_CACHE_HOME", "")
|
||||
got, err := xdg.Path("XDG_CACHE_HOME", ".cache", "server-info.yaml")
|
||||
if err != nil {
|
||||
t.Fatalf("Path: %v", err)
|
||||
}
|
||||
if !filepath.IsAbs(got) {
|
||||
t.Errorf("expected absolute path, got %q", got)
|
||||
}
|
||||
if !strings.Contains(got, ".cache") || !strings.Contains(got, "academy") {
|
||||
t.Errorf("expected ~/.cache/academy prefix, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteAtomicYAML_RoundTrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
p := filepath.Join(dir, "sub", "file.yaml")
|
||||
type doc struct {
|
||||
Name string `yaml:"name"`
|
||||
}
|
||||
if err := xdg.WriteAtomicYAML(p, &doc{Name: "alice"}); err != nil {
|
||||
t.Fatalf("WriteAtomicYAML: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(p); err != nil {
|
||||
t.Fatalf("file not written: %v", err)
|
||||
}
|
||||
if runtime.GOOS != "windows" {
|
||||
info, _ := os.Stat(p)
|
||||
if mode := info.Mode().Perm(); mode != 0o600 {
|
||||
t.Errorf("mode = %v, want 0600", mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user