fix: align group management APIs

This commit is contained in:
richjohnrambo
2026-09-13 16:03:55 +08:00
parent f1279ac607
commit a9afc6ff6a
34 changed files with 1381 additions and 639 deletions
+55
View File
@@ -3540,6 +3540,61 @@ func TestHandleBroadcastDataWithAttachments(t *testing.T) {
}
}
func TestHandleBroadcastDataInfersAttachmentFromContentFileID(t *testing.T) {
numUsers := 2
helper := TopicTestHelper{}
helper.setUp(t, numUsers, types.TopicCatP2P, "p2p-test", true)
defer helper.tearDown()
helper.mm.EXPECT().Save(types.TenantID(1), gomock.Any(), []string{"/v0/file/s/KJ0Qlrk4Gzw"}, gomock.Any()).
Return(&types.MessageSaveResult{SeqId: 1, MarkedReadBySender: true}, nil)
from := helper.uids[0].UserId()
msg := &ClientComMessage{
AsUser: from,
Original: from,
Pub: &MsgClientPub{
Topic: "p2p",
Content: map[string]any{
"file_id": "KJ0Qlrk4Gzw",
"mime": "audio/mpeg",
"size": 14143,
"duration_ms": 3719,
},
Head: map[string]any{
"x-im-type": "voice",
},
NoEcho: true,
},
sess: helper.sessions[0],
}
helper.topic.handleClientMsg(msg)
helper.finish()
if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError {
t.Fatal(errorMsgs[0].Ctrl.Text)
}
if len(helper.results[1].messages) != 1 {
t.Fatalf("Uid2: expected 1 message, got %d", len(helper.results[1].messages))
}
}
func TestMessageAttachmentURLsDeduplicatesExplicitAndContentFileID(t *testing.T) {
msg := &ClientComMessage{
Extra: &MsgClientExtra{Attachments: []string{"/v0/file/s/KJ0Qlrk4Gzw"}},
Pub: &MsgClientPub{
Content: map[string]any{
"file_id": "KJ0Qlrk4Gzw",
"mime": "audio/mpeg",
},
},
}
attachments := messageAttachmentURLs(msg)
if len(attachments) != 1 || attachments[0] != "/v0/file/s/KJ0Qlrk4Gzw" {
t.Fatalf("unexpected attachments: %#v", attachments)
}
}
func TestHandleBroadcastInfoChannelWithMultipleReaders(t *testing.T) {
topicName := "grpTest"
chanName := "chnTest"