Created
November 8, 2023 06:43
-
-
Save kvii/a858edfd1bf4daecaf713d487be4be41 to your computer and use it in GitHub Desktop.
get groups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rpcclient | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"testing" | |
"github.com/OpenIMSDK/protocol/constant" | |
"github.com/OpenIMSDK/protocol/group" | |
"github.com/OpenIMSDK/protocol/sdkws" | |
"google.golang.org/api/option" | |
"google.golang.org/api/transport/grpc" | |
"google.golang.org/grpc/metadata" | |
) | |
// 先部署个什么数据都没有的后台,然后开放 Group 服务的 10150 端口。 | |
func TestGroupClient_GetGroups(t *testing.T) { | |
md := metadata.New(map[string]string{ | |
constant.OperationID: "1", | |
}) | |
ctx := context.Background() | |
ctx = metadata.NewOutgoingContext(ctx, md) | |
conn, err := grpc.DialInsecure(ctx, option.WithEndpoint("127.0.0.1:10150")) | |
if err != nil { | |
t.Fatal(err) | |
} | |
client := group.NewGroupClient(conn) | |
reply, err := client.GetGroups(ctx, &group.GetGroupsReq{ | |
Pagination: &sdkws.RequestPagination{ | |
PageNumber: 1, | |
ShowNumber: 1, | |
}, | |
GroupName: "", | |
GroupID: "", | |
}) | |
if err != nil { | |
t.Fatal(err) | |
} | |
bs, _ := json.Marshal(reply) | |
fmt.Println(string(bs)) | |
// got: | |
// {"total":0,"groups":null} | |
// expect: | |
// {"total":0,"groups":[]} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment