wallet_test.go 659 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package Service
  2. import (
  3. "fmt"
  4. "sync"
  5. "testing"
  6. "time"
  7. "encoding/json"
  8. "go-common/app/job/live/wallet/conf"
  9. "go-common/app/job/live/wallet/model"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. once sync.Once
  14. s *Service
  15. )
  16. func startService() {
  17. if err := conf.Init(); err != nil {
  18. panic(fmt.Sprintf("conf.Init() error(%v)", err))
  19. }
  20. s = New(conf.Conf)
  21. }
  22. func TestMergeData(t *testing.T) {
  23. Convey("Cache update", t, func() {
  24. once.Do(startService)
  25. time.Sleep(time.Second)
  26. m := &model.Message{}
  27. user := &model.User{}
  28. m.New, _ = json.Marshal(user)
  29. m.Old, _ = json.Marshal(user)
  30. s.mergeData(m.New, m.Old, "update")
  31. })
  32. }