123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package test
- import (
- "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/config"
- "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledgeclient"
- "context"
- "flag"
- "github.com/zeromicro/go-zero/core/conf"
- "github.com/zeromicro/go-zero/zrpc"
- "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.EntId = 14929
- req.Question = "超级订阅为什么购买不了"
- req.Answer = "超级订阅按购买区域、时间计价,您看下购买页,是否有选择购买的省份,选择购买的区域后,系统会自动计价,您下单购买就可以了。"
- req.EntUserId = 4315
- 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.EntId = 14929
- req.PageSize = 20
- req.PageIndex = 3
- 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 = 23
- 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 = 23
- req.KnowledgeId = 1
- req.EntId = 10000
- req.Question = "大会员权益有哪些,如何购买?"
- req.Answer = "大会员有超级多的权益,好处多多,在剑鱼网站直接购买。"
- res, err := TestSystem.KnowledgeEdit(ctx, req)
- log.Println("res ", res)
- log.Println("err ", err)
- }
- func Test_KnowledgeDel(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
- TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
- req := &knowledgeclient.KnowledgeDelReq{}
- req.AnswerId = 32
- res, err := TestSystem.KnowledgeDel(ctx, req)
- log.Println("res ", res)
- log.Println("err ", err)
- }
- func Test_FindAnswer(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
- TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
- req := &knowledgeclient.FindAnswerReq{}
- req.Question = "超级订阅为什么购买不了"
- req.RobotEntId = "455b495c5c"
- req.Type = 1
- res, err := TestSystem.FindAnswer(ctx, req)
- log.Println("res ", res)
- log.Println("err ", err)
- }
- func Test_RecommendAnswer(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
- TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
- req := &knowledgeclient.FindAnswerReq{}
- req.Question = "大会员"
- req.RobotEntId = "455b495c5c"
- req.Type = 1
- res, err := TestSystem.RecommendAnswer(ctx, req)
- log.Println("res ", res)
- log.Println("err ", err)
- }
|