base_distributor_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package base
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. model "dashoo.cn/micro/app/model/base"
  7. modelWorkflow "dashoo.cn/micro/app/model/workflow"
  8. "dashoo.cn/micro/app/service"
  9. "dashoo.cn/opms_libary/plugin/dingtalk/message"
  10. "github.com/gogf/gf/frame/g"
  11. "github.com/smallnest/rpcx/share"
  12. )
  13. var testTenant = "default"
  14. func fakeCtx(parent context.Context, tenant string) context.Context {
  15. ctx := context.WithValue(parent, share.ReqMetaDataKey, map[string]string{
  16. "tenant": tenant,
  17. })
  18. return ctx
  19. }
  20. func TestApprovalProxyCreate(t *testing.T) {
  21. ctx := fakeCtx(context.Background(), testTenant)
  22. instance := modelWorkflow.PlatWorkflow{}
  23. err := g.DB(testTenant).Table("plat_workflow").Where("id = ?", 155).Struct(&instance)
  24. if err != nil {
  25. panic(err)
  26. }
  27. err = ApprovalDistToProxy(ctx, &instance, &message.MixMessage{
  28. ProcessType: "finish",
  29. // ProcessType: "terminate",
  30. Result: "agree",
  31. // Result: "refuse",
  32. })
  33. if err != nil {
  34. panic(err)
  35. }
  36. }
  37. func TestCreateSystemMessage(t *testing.T) {
  38. ent := model.BaseDistributor{}
  39. ent.DistName = "测试经销商123323223"
  40. ent.DistType = "10"
  41. ent.Id = 59
  42. // ent.DistName = "测试审批"
  43. // ent.DistType = "20"
  44. // ent.Id = 38
  45. msg := g.MapStrStr{
  46. "msgTitle": "经销商信息完善提醒",
  47. "msgContent": fmt.Sprintf("<p>经销商:<a href='%s'>%s</a> 的必要信息未填写完整,请及时完善</p>", distUrl(ent), ent.DistName),
  48. "msgType": "20",
  49. "msgStatus": "10",
  50. "recvUserIds": "1",
  51. "sendType": "10,20,30",
  52. }
  53. if err := service.CreateSystemMessage(msg); err != nil {
  54. t.Errorf("CreateSystemMessage() error = %v", err)
  55. }
  56. }
  57. func TestNotifyToComplete(t *testing.T) {
  58. notifyToComplete()
  59. }