redis_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/thumbup/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaohashStatsKey(t *testing.T) {
  9. convey.Convey("hashStatsKey", t, func(convCtx convey.C) {
  10. var (
  11. businessID = int64(33)
  12. originID = int64(7788)
  13. )
  14. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  15. p1 := hashStatsKey(businessID, originID)
  16. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  17. convCtx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoExpireHashStatsCache(t *testing.T) {
  23. convey.Convey("ExpireHashStatsCache", t, func(convCtx convey.C) {
  24. var (
  25. c = context.Background()
  26. businessID = int64(33)
  27. originID = int64(7788)
  28. )
  29. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  30. ok, err := d.ExpireHashStatsCache(c, businessID, originID)
  31. convCtx.Convey("Then err should be nil.ok should not be nil.", func(convCtx convey.C) {
  32. convCtx.So(err, convey.ShouldBeNil)
  33. convCtx.So(ok, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoAddHashStatsCache(t *testing.T) {
  39. convey.Convey("AddHashStatsCache", t, func(convCtx convey.C) {
  40. var (
  41. c = context.Background()
  42. businessID = int64(33)
  43. originID = int64(7788)
  44. stats = &model.Stats{}
  45. )
  46. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  47. err := d.AddHashStatsCache(c, businessID, originID, stats)
  48. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  49. convCtx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. })
  53. }