fix: return saved group nickname profile
This commit is contained in:
@@ -3835,6 +3835,44 @@ func TestServeIMGroupMyProfileKeepsSubscriptionNicknameWhenBusinessMemberMissing
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeIMGroupMyProfileGetReturnsSubscriptionNickname(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
expectIMBearer(t, ctrl, "token-1", 7, 42)
|
||||
oldSubs := store.Subs
|
||||
subs := mock_store.NewMockSubsPersistenceInterface(ctrl)
|
||||
store.Subs = subs
|
||||
defer func() {
|
||||
store.Subs = oldSubs
|
||||
}()
|
||||
|
||||
subs.EXPECT().Get(types.TenantID(7), "grpAlpha", types.Uid(42), false).Return(&types.Subscription{
|
||||
TenantID: 7,
|
||||
User: types.Uid(42).String(),
|
||||
Topic: "grpAlpha",
|
||||
ModeWant: types.ModeCFull,
|
||||
ModeGiven: types.ModeCFull,
|
||||
Private: map[string]any{
|
||||
"nickname": "Coffee 备注",
|
||||
"profile_version": 3,
|
||||
"profile_updated_at": "2026-09-03T01:00:00Z",
|
||||
},
|
||||
}, nil)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/v1/im/groups/grpAlpha/members/me/profile", nil)
|
||||
req.Header.Set("Authorization", "Bearer token-1")
|
||||
rec := httptest.NewRecorder()
|
||||
serveIMGroupResource(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("profile get status: got %d body=%s", rec.Code, rec.Body.String())
|
||||
}
|
||||
data := decodeIMHTTPResponse(t, rec).Data.(map[string]any)
|
||||
if data["nickname"] != "Coffee 备注" || data["version"].(float64) != 3 || data["updated_at"] != "2026-09-03T01:00:00Z" {
|
||||
t.Fatalf("unexpected profile get response: %#v", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServeIMGroupLeave(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
Reference in New Issue
Block a user