You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

proxy_test.go 1.2 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package tm
  2. import (
  3. "context"
  4. "github.com/dk-lockdown/seata-golang/client/config"
  5. getty2 "github.com/dk-lockdown/seata-golang/client/getty"
  6. "github.com/stretchr/testify/assert"
  7. "testing"
  8. )
  9. type Dog struct {
  10. }
  11. type Cat struct {
  12. }
  13. type ZooService struct {
  14. }
  15. func (svc *ZooService) ManageAnimal(ctx context.Context,dog *Dog,cat *Cat) (bool,error) {
  16. return true,nil
  17. }
  18. type TestService struct {
  19. *ZooService
  20. ManageAnimal func(ctx context.Context,dog *Dog,cat *Cat) (bool,error)
  21. }
  22. var methodTransactionInfo = make(map[string]*TransactionInfo)
  23. func init() {
  24. methodTransactionInfo["ManageAnimal"] = &TransactionInfo{
  25. TimeOut: 60000,
  26. Name: "",
  27. Propagation: REQUIRED,
  28. }
  29. }
  30. func (svc *TestService) GetProxyService() interface{} {
  31. return svc.ZooService
  32. }
  33. func (svc *TestService) GetMethodTransactionInfo(methodName string) *TransactionInfo {
  34. return methodTransactionInfo[methodName]
  35. }
  36. func TestProxy_Implement(t *testing.T) {
  37. config.InitConfWithDefault("testService")
  38. getty2.InitRpcClient()
  39. NewTMClient()
  40. zooSvc := &ZooService{}
  41. ts := &TestService{ZooService: zooSvc}
  42. Implement(ts)
  43. result, err := ts.ManageAnimal(context.Background(),&Dog{},&Cat{})
  44. assert.True(t,result)
  45. assert.Nil(t,err)
  46. }

Go Implementation For Seata