| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package cust
- import (
- "context"
- "testing"
- modelWorkflow "dashoo.cn/micro/app/model/workflow"
- "dashoo.cn/opms_libary/plugin/dingtalk/message"
- "github.com/gogf/gf/frame/g"
- "github.com/smallnest/rpcx/share"
- )
- var testTenant = "default"
- func fakeCtx(parent context.Context, tenant string) context.Context {
- ctx := context.WithValue(parent, share.ReqMetaDataKey, map[string]string{
- "tenant": tenant,
- })
- return ctx
- }
- func TestAssignCustomerRequestApproval(t *testing.T) {
- ctx := fakeCtx(context.Background(), testTenant)
- srv, err := NewCustomerService(ctx)
- if err != nil {
- panic(err)
- }
- instance := modelWorkflow.PlatWorkflow{}
- err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 33).Struct(&instance)
- if err != nil {
- panic(err)
- }
- err = srv.AssignCustomerRequestApproval(&instance, &message.MixMessage{
- ProcessType: "finish",
- // ProcessType: "terminate",
- Result: "agree",
- // Result: "refuse",
- })
- if err != nil {
- panic(err)
- }
- }
- func TestAssignMoveToPublicApproval(t *testing.T) {
- ctx := fakeCtx(context.Background(), testTenant)
- srv, err := NewCustomerService(ctx)
- if err != nil {
- panic(err)
- }
- instance := modelWorkflow.PlatWorkflow{}
- err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 25).Struct(&instance)
- if err != nil {
- panic(err)
- }
- err = srv.MoveToPublicApproval(&instance, &message.MixMessage{
- ProcessType: "finish",
- // ProcessType: "terminate",
- Result: "agree",
- // Result: "refuse",
- })
- if err != nil {
- panic(err)
- }
- }
- func TestAssignTransCustomerApproval(t *testing.T) {
- ctx := fakeCtx(context.Background(), testTenant)
- srv, err := NewCustomerService(ctx)
- if err != nil {
- panic(err)
- }
- instance := modelWorkflow.PlatWorkflow{}
- err = g.DB(testTenant).Table("plat_workflow").Where("id = ?", 27).Struct(&instance)
- if err != nil {
- panic(err)
- }
- err = srv.TransCustomerApproval(&instance, &message.MixMessage{
- ProcessType: "finish",
- // ProcessType: "terminate",
- Result: "agree",
- // Result: "refuse",
- })
- if err != nil {
- panic(err)
- }
- }
|