You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/msgprocessor/conversation_test.go

335 lines
7.1 KiB

☀️ feat: Enhancing OpenIM with Integrated E2E Testing and CI/CD Enhancements (#1359) * cicd: robot automated Change * feat: add api test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add api test make file Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim e2e test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim e2e test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: Fixed some unused scripts and some names Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * docs: optimize openim docs Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add prom address Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim info test * feat: add openim images config path Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix tim file rename * fix: fix tim file rename * fix: fix tim file rename * fix: fix tim file rename * fix: add openim test e2e * feat: add openim test .keep Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim test .keep Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: cubxxw <cubxxw@users.noreply.github.com>
1 year ago
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package msgprocessor
import (
"testing"
refactor: 3.7.0 code conventions. (#2148) * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: add code lint * feat: add code lint * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: code format * Script Refactoring * Script Refactoring * Script Refactoring * Adjust MinIO configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: config change. * refactor: webhooks update. * Adjust configuration settings * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * feat: s3 api addr * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: webhooks update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * refactor: kafka update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Windows can compile and run. * Windows can compile and run. * refactor: kafka update. * feat: msg cache split * refactor: webhooks update * refactor: webhooks update * refactor: friends update * refactor: group update * refactor: third update * refactor: api update * refactor: crontab update * refactor: msggateway update * mage * mage * refactor: all module update. * check * refactor: all module update. * load config * load config * load config * load config * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update tools * update tools * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update protocol * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: api remove token auth by redis directly. * Code Refactoring * refactor: websocket auth change to call rpc of auth. * refactor: kick online user and remove token change to call auth rpc. * refactor: kick online user and remove token change to call auth rpc. * refactor: remove msggateway redis. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * fix: runtime: goroutine stack exceeds * refactor: cmd update. * refactor notification * refactor notification * refactor * refactor: cmd update. * refactor: cmd update. * refactor * refactor * refactor * protojson * protojson * protojson * go mod * wrapperspb * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: context update. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: api name change. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: update file * refactor * refactor * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: callback update. * fix: callback update. * refactor * fix: update message. * fix: msg cache timeout. * refactor * refactor * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: websocket handle error remove when upgrade error. --------- Co-authored-by: skiffer-git <44203734@qq.com> Co-authored-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <993506633@qq.com>
8 months ago
"github.com/openimsdk/protocol/sdkws"
☀️ feat: Enhancing OpenIM with Integrated E2E Testing and CI/CD Enhancements (#1359) * cicd: robot automated Change * feat: add api test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add api test make file Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim e2e test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim e2e test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: Fixed some unused scripts and some names Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * docs: optimize openim docs Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add prom address Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim info test * feat: add openim images config path Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix tim file rename * fix: fix tim file rename * fix: fix tim file rename * fix: fix tim file rename * fix: add openim test e2e * feat: add openim test .keep Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add openim test .keep Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: openim test Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: cubxxw <cubxxw@users.noreply.github.com>
1 year ago
"google.golang.org/protobuf/proto"
)
func TestGetNotificationConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetNotificationConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetChatConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetChatConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetChatConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGenConversationUniqueKey(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GenConversationUniqueKey(tt.args.msg); got != tt.want {
t.Errorf("GenConversationUniqueKey() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetConversationIDBySessionType(t *testing.T) {
type args struct {
sessionType int
ids []string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetConversationIDBySessionType(tt.args.sessionType, tt.args.ids...); got != tt.want {
t.Errorf("GetConversationIDBySessionType() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetNotificationConversationIDByConversationID(t *testing.T) {
type args struct {
conversationID string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationIDByConversationID(tt.args.conversationID); got != tt.want {
t.Errorf("GetNotificationConversationIDByConversationID() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetNotificationConversationID(t *testing.T) {
type args struct {
sessionType int
ids []string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationID(tt.args.sessionType, tt.args.ids...); got != tt.want {
t.Errorf("GetNotificationConversationID() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsNotification(t *testing.T) {
type args struct {
conversationID string
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsNotification(tt.args.conversationID); got != tt.want {
t.Errorf("IsNotification() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsNotificationByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsNotificationByMsg(tt.args.msg); got != tt.want {
t.Errorf("IsNotificationByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestParseConversationID(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
wantIsNotification bool
wantConversationID string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotIsNotification, gotConversationID := ParseConversationID(tt.args.msg)
if gotIsNotification != tt.wantIsNotification {
t.Errorf("ParseConversationID() gotIsNotification = %v, want %v", gotIsNotification, tt.wantIsNotification)
}
if gotConversationID != tt.wantConversationID {
t.Errorf("ParseConversationID() gotConversationID = %v, want %v", gotConversationID, tt.wantConversationID)
}
})
}
}
func TestMsgBySeq_Len(t *testing.T) {
tests := []struct {
name string
s MsgBySeq
want int
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.s.Len(); got != tt.want {
t.Errorf("MsgBySeq.Len() = %v, want %v", got, tt.want)
}
})
}
}
func TestMsgBySeq_Less(t *testing.T) {
type args struct {
i int
j int
}
tests := []struct {
name string
s MsgBySeq
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.s.Less(tt.args.i, tt.args.j); got != tt.want {
t.Errorf("MsgBySeq.Less() = %v, want %v", got, tt.want)
}
})
}
}
func TestMsgBySeq_Swap(t *testing.T) {
type args struct {
i int
j int
}
tests := []struct {
name string
s MsgBySeq
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.s.Swap(tt.args.i, tt.args.j)
})
}
}
func TestPb2String(t *testing.T) {
type args struct {
pb proto.Message
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Pb2String(tt.args.pb)
if (err != nil) != tt.wantErr {
t.Errorf("Pb2String() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Pb2String() = %v, want %v", got, tt.want)
}
})
}
}
func TestString2Pb(t *testing.T) {
type args struct {
s string
pb proto.Message
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := String2Pb(tt.args.s, tt.args.pb); (err != nil) != tt.wantErr {
t.Errorf("String2Pb() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}