wallet_test.go 881 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package dao
  2. import (
  3. "context"
  4. "sync"
  5. "testing"
  6. "time"
  7. "go-common/app/job/live/wallet/conf"
  8. "go-common/library/log"
  9. . "github.com/smartystreets/goconvey/convey"
  10. "go-common/app/job/live/wallet/model"
  11. )
  12. var (
  13. once sync.Once
  14. d *Dao
  15. ctx = context.TODO()
  16. testUid int64
  17. )
  18. func initConf() {
  19. if err := conf.Init(); err != nil {
  20. panic(err)
  21. }
  22. log.Init(conf.Conf.Log)
  23. defer log.Close()
  24. }
  25. func startService() {
  26. initConf()
  27. d = New(conf.Conf)
  28. time.Sleep(time.Second * 2)
  29. }
  30. func TestInitWallet(t *testing.T) {
  31. Convey("Init Wallet", t, func() {
  32. once.Do(startService)
  33. user := &model.User{}
  34. user.Uid = testUid
  35. _, err := d.InitWallet(ctx, user)
  36. So(err, ShouldBeNil)
  37. })
  38. }
  39. func TestMergeWallet(t *testing.T) {
  40. Convey("Merge Wallet", t, func() {
  41. once.Do(startService)
  42. _, err := d.MergeWallet(ctx, testUid, 1, 2, 3)
  43. So(err, ShouldBeNil)
  44. })
  45. }