package service 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 TestAssignInvoiceApplyApproval(t *testing.T) { ctx := fakeCtx(context.Background(), testTenant) instance := modelWorkflow.PlatWorkflow{} err := g.DB(testTenant).Table("plat_workflow").Where("id = ?", 47).Struct(&instance) if err != nil { panic(err) } err = InvoiceApplyApproval(ctx, &instance, &message.MixMessage{ ProcessType: "finish", // ProcessType: "terminate", // Result: "agree", Result: "refuse", }) if err != nil { panic(err) } } func TestContractApplyApproval(t *testing.T) { ctx := fakeCtx(context.Background(), testTenant) instance := modelWorkflow.PlatWorkflow{} err := g.DB(testTenant).Table("plat_workflow").Where("id = ?", 85).Struct(&instance) if err != nil { panic(err) } err = ContractApplyApproval(ctx, &instance, &message.MixMessage{ ProcessType: "finish", // ProcessType: "terminate", Result: "agree", // Result: "refuse", }) if err != nil { panic(err) } }