Add TestSyncAvatarsFromGitHub().

This commit is contained in:
Yang Luo
2021-03-28 21:50:00 +08:00
parent cc8485a7db
commit bc368a4361
2 changed files with 40 additions and 0 deletions

31
object/user_test.go Normal file
View File

@ -0,0 +1,31 @@
package object
import (
"fmt"
"testing"
"xorm.io/core"
)
func updateUserAvatar(user *User) bool {
affected, err := adapter.engine.ID(core.PK{user.Owner, user.Name}).Cols("avatar").Update(user)
if err != nil {
panic(err)
}
return affected != 0
}
func TestSyncAvatarsFromGitHub(t *testing.T) {
InitConfig()
users := GetGlobalUsers()
for _, user := range users {
if user.Github == "" {
continue
}
user.Avatar = fmt.Sprintf("https://avatars.githubusercontent.com/%s", user.Github)
updateUserAvatar(user)
}
}