Skip to content

Commit

Permalink
Add TestPrintChatUsers()
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 9, 2024
1 parent 2d7b904 commit 4a150c7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions object/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package object

import (
"fmt"
"sort"
"testing"

"github.com/casibase/casibase/model"
Expand Down Expand Up @@ -144,3 +145,27 @@ func TestUpdateChatDescs(t *testing.T) {
}
}
}

func TestPrintChatUsers(t *testing.T) {
InitConfig()

chats, err := GetGlobalChats()
if err != nil {
panic(err)
}

userMap := make(map[string]struct{})
var users []string
for _, chat := range chats {
if _, exists := userMap[chat.User]; !exists {
userMap[chat.User] = struct{}{}
users = append(users, chat.User)
}
}

sort.Strings(users)

for _, user := range users {
fmt.Printf("%s\n", user)
}
}

0 comments on commit 4a150c7

Please sign in to comment.