🐛 fix(spx): 同一 host 有多条 tea login 时优先取 default,不再固定取第一条
This commit is contained in:
1 parent
3e3de0ae07
commit
e6d086d821
2 files changed
+31
-4
No files matched your search
@@ -67,3 +67,22 @@ func TestLoginForHostBadYAMLIsAnError(t *testing.T) {
|
||||
t.Fatal("tea config 解析失败应当报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginForHostPrefersDefaultAmongSameHost(t *testing.T) {
|
||||
path := writeConfig(t, `logins:
|
||||
- name: bot
|
||||
url: https://gitea.example.com
|
||||
token: tok-bot
|
||||
- name: me
|
||||
url: https://gitea.example.com/
|
||||
token: tok-me
|
||||
default: true
|
||||
`)
|
||||
l, err := LoginForHost(path, "gitea.example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("LoginForHost 出错: %v", err)
|
||||
}
|
||||
if l == nil || l.Name != "me" {
|
||||
t.Fatalf("同一 host 有多条 login 时应取 default 那条,得到 %+v", l)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user