feat: 基础框架搭建完毕
Checks / verify (push) Failing after 2m37s

This commit is contained in:
2026-10-07 09:27:47 +08:00
parent ba6dfffab7
commit bffdb3858b
64 changed files with 326 additions and 332 deletions
+25
View File
@@ -0,0 +1,25 @@
package config
import (
"net/url"
"testing"
)
func TestDatabaseURLPreservesCredentials(t *testing.T) {
c := Config{PGHost: "192.168.100.127", PGPort: "5432", PGUser: "user@name", PGPassword: "p@ss:/?#&", PGSSLMode: "require"}
u, err := url.Parse(c.DatabaseURL("veyra"))
if err != nil {
t.Fatal(err)
}
password, _ := u.User.Password()
if password != c.PGPassword || u.User.Username() != c.PGUser || u.Path != "/veyra" || u.Query().Get("sslmode") != "require" {
t.Fatal("connection URL changed configuration values")
}
}
func TestRejectInvalidRedisDB(t *testing.T) {
t.Setenv("REDIS_DB", "-1")
if _, err := Load(); err == nil {
t.Fatal("negative database must be rejected")
}
}