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.

branch_session_test.go 1.0 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637
  1. package session
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "github.com/dk-lockdown/seata-golang/meta"
  5. "github.com/dk-lockdown/seata-golang/util"
  6. "testing"
  7. )
  8. func TestBranchSession_Encode_Decode(t *testing.T) {
  9. bs := branchSessionProvider()
  10. result,_ := bs.Encode()
  11. newBs := &BranchSession{}
  12. newBs.Decode(result)
  13. assert.Equal(t,bs.TransactionId,newBs.TransactionId)
  14. assert.Equal(t,bs.BranchId,newBs.BranchId)
  15. assert.Equal(t,bs.ResourceId,newBs.ResourceId)
  16. assert.Equal(t,bs.LockKey,newBs.LockKey)
  17. assert.Equal(t,bs.ClientId,newBs.ClientId)
  18. assert.Equal(t,bs.ApplicationData,newBs.ApplicationData)
  19. }
  20. func branchSessionProvider() *BranchSession {
  21. bs := NewBranchSession().
  22. SetTransactionId(util.GeneratorUUID()).
  23. SetBranchId(1).
  24. SetResourceGroupId("my_test_tx_group").
  25. SetResourceId("tb_1").
  26. SetLockKey("t_1").
  27. SetBranchType(meta.BranchTypeAT).
  28. SetStatus(meta.BranchStatusUnknown).
  29. SetClientId("c1").
  30. SetApplicationData([]byte("{\"data\":\"test\"}"))
  31. return bs
  32. }

Go Implementation For Seata