* feat(codex): support custom base URL * fix(codex): require HTTPS for custom base URL * docs: document changed subscription functions * fix(groups): 展示并区分详情中的默认与自定义地址 * fix(groups): 统一上游地址配置交互与图标位置 * fix(subscription): 绑定额度重置操作的上游地址 * fix(gateway): 隔离旧上游请求的健康状态更新 --------- Co-authored-by: tbphp <tangb7420@gmail.com>
28 lines
762 B
Go
28 lines
762 B
Go
package subscriptionruntime
|
|
|
|
import "testing"
|
|
|
|
func TestTargetBaseURL(t *testing.T) {
|
|
for _, test := range []struct {
|
|
raw string
|
|
want string
|
|
fail bool
|
|
}{
|
|
{"", "", false},
|
|
{`{}`, "", false},
|
|
{`{"base_url":""}`, "", false},
|
|
{`{"base_url":"HTTPS://RELAY.EXAMPLE:443/team-a/"}`, "https://relay.example/team-a", false},
|
|
{`{"base_url":"http://relay.example"}`, "", true},
|
|
{`{"base_url":"https://relay.example?query=value"}`, "", true},
|
|
{`{"base_url":7}`, "", true},
|
|
{`invalid`, "", true},
|
|
} {
|
|
t.Run(test.raw, func(t *testing.T) {
|
|
got, err := NewTarget([]byte(test.raw)).BaseURL()
|
|
if got != test.want || (err != nil) != test.fail {
|
|
t.Fatalf("BaseURL() = %q, %v; want %q, failure=%t", got, err, test.want, test.fail)
|
|
}
|
|
})
|
|
}
|
|
}
|