feat(core): 初始化基础框架并完善接入文档
Verify / verify (push) Canceled after 0s

抽取 Gin、配置、日志、数据库、Redis 与出站 HTTP 基础能力。
新增统一接入指南,将能力清单和相对链接检查纳入 make verify。
对齐远端 module 路径,修正 Redis 读写超时特殊值映射。

验证:make verify、make race-check 均通过。
This commit is contained in:
zhangdeman committed 2026-11-26 19:50:52 -08:00
commit b4c3ac622c
55 files changed
+5862

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
package config
import (
"errors"
"os"
"path/filepath"
"testing"
"git.zhangdeman.cn/github/ginframework/fault"
)
func TestStrictEnvironmentAndOptionalValues(t *testing.T) {
t.Setenv("GINFRAMEWORK_TEST_VALUE", "loaded")
path := filepath.Join(t.TempDir(), "config.yml")
if err := os.WriteFile(path, []byte("name: ${GINFRAMEWORK_TEST_VALUE}\ncount: 0\n"), 0600); err != nil {
t.Fatal(err)
}
var (
target struct {
Name string `yaml:"name"`
Count *int `yaml:"count"`
}
)
if err := Load(path, &target, Options{}); err != nil {
t.Fatal(err)
}
if target.Name != "loaded" || target.Count == nil || *target.Count != 0 {
t.Fatalf("configuration lost values: %+v", target)
}
if err := os.WriteFile(path, []byte("unknown: yes\n"), 0600); err != nil {
t.Fatal(err)
}
if err := Load(path, &target, Options{}); !fault.Internal(err) {
t.Fatalf("missing internal error: %v", err)
}
if err := Load(path, &target, Options{AllowUnknownFields: true}); err != nil {
t.Fatal(err)
}
}
func TestReadCauseAndMultipleDocuments(t *testing.T) {
var (
target struct {
Name string `yaml:"name"`
}
)
if err := Load(filepath.Join(t.TempDir(), "missing.yml"), &target, Options{}); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("cause lost: %v", err)
}
path := filepath.Join(t.TempDir(), "config.yml")
if err := os.WriteFile(path, []byte("name: first\n---\nname: second\n"), 0600); err != nil {
t.Fatal(err)
}
if err := Load(path, &target, Options{}); err == nil {
t.Fatal("accepted multiple configuration documents")
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.