cust_customer_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package cust
  2. import (
  3. "context"
  4. "testing"
  5. modelWorkflow "dashoo.cn/micro/app/model/workflow"
  6. "dashoo.cn/opms_libary/plugin/dingtalk/message"
  7. "github.com/gogf/gf/frame/g"
  8. "github.com/smallnest/rpcx/share"
  9. )
  10. var testTenant = "default"
  11. func fakeCtx(parent context.Context, tenant string) context.Context {
  12. ctx := context.WithValue(parent, share.ReqMetaDataKey, map[string]string{
  13. "tenant": tenant,
  14. })
  15. return ctx
  16. }
  17. func TestAssignCustomerRequestApproval(t *testing.T) {
  18. ctx := fakeCtx(context.Background(), testTenant)
  19. srv, err := NewCustomerService(ctx)
  20. if err != nil {
  21. panic(err)
  22. }
  23. instance := modelWorkflow.PlatWorkflow{}
  24. err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 33).Struct(&instance)
  25. if err != nil {
  26. panic(err)
  27. }
  28. err = srv.AssignCustomerRequestApproval(&instance, &message.MixMessage{
  29. ProcessType: "finish",
  30. // ProcessType: "terminate",
  31. Result: "agree",
  32. // Result: "refuse",
  33. })
  34. if err != nil {
  35. panic(err)
  36. }
  37. }
  38. func TestAssignMoveToPublicApproval(t *testing.T) {
  39. ctx := fakeCtx(context.Background(), testTenant)
  40. srv, err := NewCustomerService(ctx)
  41. if err != nil {
  42. panic(err)
  43. }
  44. instance := modelWorkflow.PlatWorkflow{}
  45. err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 25).Struct(&instance)
  46. if err != nil {
  47. panic(err)
  48. }
  49. err = srv.MoveToPublicApproval(&instance, &message.MixMessage{
  50. ProcessType: "finish",
  51. // ProcessType: "terminate",
  52. Result: "agree",
  53. // Result: "refuse",
  54. })
  55. if err != nil {
  56. panic(err)
  57. }
  58. }
  59. func TestAssignTransCustomerApproval(t *testing.T) {
  60. ctx := fakeCtx(context.Background(), testTenant)
  61. srv, err := NewCustomerService(ctx)
  62. if err != nil {
  63. panic(err)
  64. }
  65. instance := modelWorkflow.PlatWorkflow{}
  66. err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 27).Struct(&instance)
  67. if err != nil {
  68. panic(err)
  69. }
  70. err = srv.TransCustomerApproval(&instance, &message.MixMessage{
  71. ProcessType: "finish",
  72. // ProcessType: "terminate",
  73. Result: "agree",
  74. // Result: "refuse",
  75. })
  76. if err != nil {
  77. panic(err)
  78. }
  79. }