12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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 = "超级订阅用户权益有订阅设置。"
- 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 = 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.TenantId = 10000
- req.Question = "大会员权益有哪些,如何购买?"
- req.Answer = "大会员有超级多的权益,好处多多,在剑鱼网站直接购买。"
- res, err := TestSystem.KnowledgeEdit(ctx, req)
- log.Println("res ", res)
- log.Println("err ", err)
- }
|