From 575a248c41d76210cab7972c171e0157580755d6 Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Thu, 22 Sep 2022 20:51:50 +0800 Subject: [PATCH] Add TestGetEmailsForUsers() --- object/user_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/object/user_test.go b/object/user_test.go index 8b080582..760fc23c 100644 --- a/object/user_test.go +++ b/object/user_test.go @@ -17,6 +17,7 @@ package object import ( "fmt" "reflect" + "strings" "testing" "github.com/casdoor/casdoor/util" @@ -108,3 +109,24 @@ func TestGetUserByField(t *testing.T) { t.Log("no user found") } } + +func TestGetEmailsForUsers(t *testing.T) { + InitConfig() + + emailMap := map[string]int{} + emails := []string{} + users := GetUsers("built-in") + for _, user := range users { + if user.Email == "" { + continue + } + + if _, ok := emailMap[user.Email]; !ok { + emailMap[user.Email] = 1 + emails = append(emails, user.Email) + } + } + + text := strings.Join(emails, "\n") + println(text) +}