mc.extra_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/ugcpay-rank/internal/model"
  6. "go-common/library/cache/memcache"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoCASCacheElecPrepRank(t *testing.T) {
  10. convey.Convey("CASCacheElecPrepRank", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. val = &model.RankElecPrepUPProto{
  14. Count: 233,
  15. UPMID: 233,
  16. Size_: 10,
  17. }
  18. id int64 = 233
  19. rawItem *memcache.Item
  20. err error
  21. ver = int64(0)
  22. )
  23. _, rawItem, err = d.CacheElecPrepUPRank(c, id, ver)
  24. convey.So(err, convey.ShouldBeNil)
  25. convey.So(rawItem, convey.ShouldNotBeNil)
  26. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  27. var ok bool
  28. ok, err = d.CASCacheElecPrepRank(c, val, rawItem)
  29. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. ctx.So(ok, convey.ShouldNotBeNil)
  32. })
  33. })
  34. data, _, err := d.CacheElecPrepUPRank(c, id, ver)
  35. convey.So(err, convey.ShouldBeNil)
  36. convey.So(data, convey.ShouldResemble, val)
  37. })
  38. }