fix(config): validate DATABASE_URL required and parseable, log redis disabled (B15)
This commit is contained in:
@@ -6,6 +6,22 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLoadDatabaseURLRequired(t *testing.T) {
|
||||
t.Setenv("JWT_SECRET", "x")
|
||||
t.Setenv("DATABASE_URL", "")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("empty DATABASE_URL must fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDatabaseURLMalformed(t *testing.T) {
|
||||
t.Setenv("JWT_SECRET", "x")
|
||||
t.Setenv("DATABASE_URL", "not a url")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("malformed DATABASE_URL must fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
// 屏蔽外部 env,保证默认值断言自洽(Load 将空串视为未设置)
|
||||
t.Setenv("BOOKS_DIR", "")
|
||||
|
||||
Reference in New Issue
Block a user