package test import ( "context" "flag" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/zrpc" "knowledgeBase/rpc/knowledge/internal/config" "knowledgeBase/rpc/knowledge/knowledgeclient" "log" "testing" "time" ) var configFile = flag.String("f", "../etc/knowledge.yaml", "the config file") var c config.Config func init() { conf.MustLoad(*configFile, &c) } func Test_KnowledgeAdd(t *testing.T) { ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf)) req := &knowledgeclient.AddRequest{} req.AppId = "10000" req.TenantId = "10000" req.Question = "超级订阅在哪设置订阅提醒,订阅关键词怎么设置?" req.Answer = "可以再app中”我的“,”订阅设置“中设置。" req.Person = "王三" res, err := TestSystem.KnowledgeAdd(ctx, req) log.Println("res ", res) log.Println("err ", err) } func Test_KnowledgeList(t *testing.T) { ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf)) req := &knowledgeclient.ListRequest{} req.TenantId = 10000 req.PageSize = 10 req.PageIndex = 1 res, err := TestSystem.KnowledgeList(ctx, req) log.Println("res ", res) log.Println("err ", err) } func Test_KnowledgeInfo(t *testing.T) { ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf)) req := &knowledgeclient.KnowledgeEntity{} req.AnswerId = 1 res, err := TestSystem.KnowledgeInfo(ctx, req) log.Println("res ", res) log.Println("err ", err) } func Test_KnowledgeEdit(t *testing.T) { ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf)) req := &knowledgeclient.KnowledgeEditReq{} req.AnswerId = 1 res, err := TestSystem.KnowledgeEdit(ctx, req) log.Println("res ", res) log.Println("err ", err) }