-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser_test.go
More file actions
52 lines (44 loc) · 933 Bytes
/
user_test.go
File metadata and controls
52 lines (44 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"os"
"testing"
"valid/types/user"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/discov"
"github.com/zeromicro/go-zero/zrpc"
)
var (
ctx = context.Background()
)
// NewGrpcClient 创建indicator rpc客户端
func NewGrpcClient() user.UserClient {
client, err := zrpc.NewClient(zrpc.RpcClientConf{
Etcd: discov.EtcdConf{
Hosts: []string{"192.168.2.230:2379"},
Key: "user.rpc",
InsecureSkipVerify: false,
},
Timeout: 2000,
})
if err != nil {
os.Exit(0)
}
cc := client.Conn()
ic := user.NewUserClient(cc)
return ic
}
func TestCreate(t *testing.T) {
ic := NewGrpcClient()
want := "Ok"
cr, err := ic.Create(ctx, &user.CreateRequest{
Name: "yother",
Age: 20,
Email: "yother233@gmail.com",
})
if err != nil {
t.Error(err.Error())
}
t.Logf("response:%+v", cr)
assert.Equal(t, want, cr.GetMsg())
}