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) }