redis_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/up-rating/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoGetUpRatingCache(t *testing.T) {
  9. convey.Convey("GetUpRatingCache", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(0)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. _, err := d.GetUpRatingCache(c, mid)
  16. ctx.Convey("Then err should be nil.rating should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoSetUpRatingCache(t *testing.T) {
  23. convey.Convey("SetUpRatingCache", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. mid = int64(0)
  27. rating = &model.Rating{}
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. err := d.SetUpRatingCache(c, mid, rating)
  31. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestDaoupRatingKey(t *testing.T) {
  38. convey.Convey("upRatingKey", t, func(ctx convey.C) {
  39. var (
  40. mid = int64(0)
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. p1 := upRatingKey(mid)
  44. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  45. ctx.So(p1, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }