From 2e861a692940cc6fe3e35ebab45f1ef4d8f422aa Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 11:55:28 +0000 Subject: [PATCH] Add test for SearchMsg function when no chatLogs in database --- internal/rpc/msg/search_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 internal/rpc/msg/search_test.go diff --git a/internal/rpc/msg/search_test.go b/internal/rpc/msg/search_test.go new file mode 100644 index 000000000..5d9b5830d --- /dev/null +++ b/internal/rpc/msg/search_test.go @@ -0,0 +1,25 @@ +package msg + +import ( + "testing" + "github.com/OpenIMSDK/Open-IM-Server/internal/logic/service" + "github.com/OpenIMSDK/Open-IM-Server/pkg/pb" +) + +func TestSearchMsg(t *testing.T) { + // Ensure that the database is empty + // clearDatabase() + + // Call the SearchMsg function + req := &pb.SearchMsgReq{} + resp, err := service.NewMsgService().SearchMsg(context.Background(), req) + + // Check that the error is nil and the response is empty + if err != nil { + t.Errorf("Expected nil error, got %v", err) + } + if resp != &pb.SearchMsgResp{} { + t.Errorf("Expected empty response, got %v", resp) + } +} +