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.

tcc_service_test.go 1.5 kB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package test
  2. import (
  3. "context"
  4. "github.com/seata/seata-go/pkg/common/model"
  5. _ "github.com/seata/seata-go/pkg/imports"
  6. "github.com/seata/seata-go/pkg/rm/tcc"
  7. "github.com/seata/seata-go/pkg/rm/tcc/api"
  8. "github.com/seata/seata-go/pkg/rm/tcc/remoting"
  9. "github.com/seata/seata-go/pkg/utils/log"
  10. "testing"
  11. )
  12. type TestTCCServiceBusiness struct {
  13. }
  14. func (T TestTCCServiceBusiness) Prepare(ctx context.Context, params interface{}) error {
  15. log.Infof("TestTCCServiceBusiness Prepare, param %v", params)
  16. return nil
  17. }
  18. func (T TestTCCServiceBusiness) Commit(ctx context.Context, businessActionContext api.BusinessActionContext) error {
  19. log.Infof("TestTCCServiceBusiness Commit, param %v", businessActionContext)
  20. return nil
  21. }
  22. func (T TestTCCServiceBusiness) Rollback(ctx context.Context, businessActionContext api.BusinessActionContext) error {
  23. log.Infof("TestTCCServiceBusiness Rollback, param %v", businessActionContext)
  24. return nil
  25. }
  26. func (T TestTCCServiceBusiness) GetActionName() string {
  27. return "TestTCCServiceBusiness"
  28. }
  29. func (T TestTCCServiceBusiness) GetRemoteType() remoting.RemoteType {
  30. return remoting.RemoteTypeLocalService
  31. }
  32. func (T TestTCCServiceBusiness) GetServiceType() remoting.ServiceType {
  33. return remoting.ServiceTypeProvider
  34. }
  35. func TestNew(test *testing.T) {
  36. tccService := tcc.NewTCCServiceProxy(TestTCCServiceBusiness{})
  37. tccService.Prepare(model.InitSeataContext(context.Background()), 1)
  38. //time.Sleep(time.Second * 1000)
  39. }

Go Implementation For Seata