| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package cust
- import (
- "context"
- "fmt"
- "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 = ?", 66).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 = ?", 65).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 = ?", 67).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)
- }
- }
- func TestGetUser(t *testing.T) {
- ctx := context.WithValue(context.Background(), share.ReqMetaDataKey, map[string]string{
- "tenant": testTenant,
- share.AuthKey: "iuxauv5FSTslRo+jIJhl19cupXNs5/H9kZ2o5Aazkw5LFkV7hO4gRforyS4s1yvX",
- })
- err := GetUser(ctx, 1)
- fmt.Println(err)
- }
|