cust_customer_test.go 2.3 KB

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