mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Add TestSyncIds().
This commit is contained in:
parent
0fc7015c61
commit
bb5e110049
@ -4,11 +4,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/casdoor/casdoor/util"
|
||||||
"xorm.io/core"
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func updateUserAvatar(user *User) bool {
|
func updateUserColumn(column string, user *User) bool {
|
||||||
affected, err := adapter.engine.ID(core.PK{user.Owner, user.Name}).Cols("avatar").Update(user)
|
affected, err := adapter.engine.ID(core.PK{user.Owner, user.Name}).Cols(column).Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -26,6 +27,20 @@ func TestSyncAvatarsFromGitHub(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.Avatar = fmt.Sprintf("https://avatars.githubusercontent.com/%s", user.Github)
|
user.Avatar = fmt.Sprintf("https://avatars.githubusercontent.com/%s", user.Github)
|
||||||
updateUserAvatar(user)
|
updateUserColumn("avatar", user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSyncIds(t *testing.T) {
|
||||||
|
InitConfig()
|
||||||
|
|
||||||
|
users := GetGlobalUsers()
|
||||||
|
for _, user := range users {
|
||||||
|
if user.Id != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
user.Id = util.GenerateId()
|
||||||
|
updateUserColumn("id", user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user