mc_level_test.go 722 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package dao
  2. import (
  3. "context"
  4. "sync"
  5. "testing"
  6. "time"
  7. "go-common/app/job/live-userexp/conf"
  8. "go-common/app/job/live-userexp/model"
  9. "go-common/library/log"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. once sync.Once
  14. d *Dao
  15. ctx = context.TODO()
  16. )
  17. func initConf() {
  18. if err := conf.Init(); err != nil {
  19. panic(err)
  20. }
  21. log.Init(conf.Conf.Log)
  22. defer log.Close()
  23. }
  24. func startService() {
  25. initConf()
  26. d = New(conf.Conf)
  27. time.Sleep(time.Second * 2)
  28. }
  29. func TestSetLevelCache(t *testing.T) {
  30. Convey("SetLevelCache", t, func() {
  31. once.Do(startService)
  32. err := d.SetLevelCache(ctx, &model.Level{Uid: 10001, Uexp: 1000, Rexp: 100, Ulevel: 2, Rlevel: 1, Color: 12345})
  33. So(err, ShouldBeNil)
  34. })
  35. }