ctr_contract_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package service
  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 TestAssignInvoiceApplyApproval(t *testing.T) {
  18. ctx := fakeCtx(context.Background(), testTenant)
  19. instance := modelWorkflow.PlatWorkflow{}
  20. err := g.DB(testTenant).Table("plat_workflow").Where("id = ?", 47).Struct(&instance)
  21. if err != nil {
  22. panic(err)
  23. }
  24. err = InvoiceApplyApproval(ctx, &instance, &message.MixMessage{
  25. ProcessType: "finish",
  26. // ProcessType: "terminate",
  27. // Result: "agree",
  28. Result: "refuse",
  29. })
  30. if err != nil {
  31. panic(err)
  32. }
  33. }
  34. func TestContractApplyApproval(t *testing.T) {
  35. ctx := fakeCtx(context.Background(), testTenant)
  36. instance := modelWorkflow.PlatWorkflow{}
  37. err := g.DB(testTenant).Table("plat_workflow").Where("id = ?", 47).Struct(&instance)
  38. if err != nil {
  39. panic(err)
  40. }
  41. err = ContractApplyApproval(ctx, &instance, &message.MixMessage{
  42. ProcessType: "finish",
  43. // ProcessType: "terminate",
  44. // Result: "agree",
  45. Result: "refuse",
  46. })
  47. if err != nil {
  48. panic(err)
  49. }
  50. }