knowledge_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package test
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/internal/config"
  4. "bp.jydev.jianyu360.cn/SocialPlatform/knowledgeBase/rpc/knowledge/knowledgeclient"
  5. "context"
  6. "flag"
  7. "github.com/zeromicro/go-zero/core/conf"
  8. "github.com/zeromicro/go-zero/zrpc"
  9. "log"
  10. "testing"
  11. "time"
  12. )
  13. var configFile = flag.String("f", "../etc/knowledge.yaml", "the config file")
  14. var c config.Config
  15. func init() {
  16. conf.MustLoad(*configFile, &c)
  17. }
  18. func Test_KnowledgeAdd(t *testing.T) {
  19. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  20. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  21. req := &knowledgeclient.AddRequest{}
  22. req.AppId = "10000"
  23. req.EntId = 14929
  24. req.Question = "超级订阅为什么购买不了"
  25. req.Answer = "超级订阅按购买区域、时间计价,您看下购买页,是否有选择购买的省份,选择购买的区域后,系统会自动计价,您下单购买就可以了。"
  26. req.EntUserId = 4315
  27. res, err := TestSystem.KnowledgeAdd(ctx, req)
  28. log.Println("res ", res)
  29. log.Println("err ", err)
  30. }
  31. func Test_KnowledgeList(t *testing.T) {
  32. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  33. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  34. req := &knowledgeclient.ListRequest{}
  35. req.EntId = 14929
  36. req.PageSize = 20
  37. req.PageIndex = 3
  38. res, err := TestSystem.KnowledgeList(ctx, req)
  39. log.Println("res ", res)
  40. log.Println("err ", err)
  41. }
  42. func Test_KnowledgeInfo(t *testing.T) {
  43. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  44. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  45. req := &knowledgeclient.KnowledgeEntity{}
  46. req.AnswerId = 23
  47. res, err := TestSystem.KnowledgeInfo(ctx, req)
  48. log.Println("res ", res)
  49. log.Println("err ", err)
  50. }
  51. func Test_KnowledgeEdit(t *testing.T) {
  52. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  53. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  54. req := &knowledgeclient.KnowledgeEditReq{}
  55. req.AnswerId = 23
  56. req.KnowledgeId = 1
  57. req.EntId = 10000
  58. req.Question = "大会员权益有哪些,如何购买?"
  59. req.Answer = "大会员有超级多的权益,好处多多,在剑鱼网站直接购买。"
  60. res, err := TestSystem.KnowledgeEdit(ctx, req)
  61. log.Println("res ", res)
  62. log.Println("err ", err)
  63. }
  64. func Test_KnowledgeDel(t *testing.T) {
  65. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  66. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  67. req := &knowledgeclient.KnowledgeDelReq{}
  68. req.AnswerId = 32
  69. res, err := TestSystem.KnowledgeDel(ctx, req)
  70. log.Println("res ", res)
  71. log.Println("err ", err)
  72. }
  73. func Test_FindAnswer(t *testing.T) {
  74. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  75. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  76. req := &knowledgeclient.FindAnswerReq{}
  77. req.Question = "超级订阅为什么购买不了"
  78. req.RobotEntId = "455b495c5c"
  79. req.Type = 1
  80. res, err := TestSystem.FindAnswer(ctx, req)
  81. log.Println("res ", res)
  82. log.Println("err ", err)
  83. }
  84. func Test_RecommendAnswer(t *testing.T) {
  85. ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
  86. TestSystem := knowledgeclient.NewKnowledge(zrpc.MustNewClient(c.TestConf))
  87. req := &knowledgeclient.FindAnswerReq{}
  88. req.Question = "大会员"
  89. req.RobotEntId = "455b495c5c"
  90. req.Type = 1
  91. res, err := TestSystem.RecommendAnswer(ctx, req)
  92. log.Println("res ", res)
  93. log.Println("err ", err)
  94. }