fix(distribution): 修复分销后台域名登录被拦截
This commit is contained in:
@@ -48,6 +48,34 @@ func TestOpsDomain(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistributionAdminDomain(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
appEnv string
|
||||
value string
|
||||
primary string
|
||||
expected string
|
||||
}{
|
||||
{name: "开发默认", appEnv: "development", expected: "distribution.localhost"},
|
||||
{name: "生产按主域推导", appEnv: "production", primary: "hao858.com", expected: "distribution.hao858.com"},
|
||||
{
|
||||
name: "显式覆盖",
|
||||
appEnv: "production",
|
||||
value: "dist-admin.example.com",
|
||||
primary: "hao858.com",
|
||||
expected: "dist-admin.example.com",
|
||||
},
|
||||
{name: "生产无主域", appEnv: "production", expected: ""},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := distributionAdminDomain(tc.appEnv, tc.value, tc.primary); got != tc.expected {
|
||||
t.Fatalf("distributionAdminDomain() = %q, want %q", got, tc.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDatabaseConfigFromEnvironment(t *testing.T) {
|
||||
t.Setenv("DATABASE_MAX_OPEN_CONNS", "80")
|
||||
t.Setenv("DATABASE_MAX_IDLE_CONNS", "16")
|
||||
|
||||
Reference in New Issue
Block a user