redis_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package share
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestShareredisKey(t *testing.T) {
  8. var (
  9. aid = int64(1)
  10. )
  11. convey.Convey("redisKey", t, func(ctx convey.C) {
  12. p1 := redisKey(aid)
  13. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  14. ctx.So(p1, convey.ShouldNotBeNil)
  15. })
  16. })
  17. }
  18. func TestShareredisFKey(t *testing.T) {
  19. var (
  20. mid = int64(1)
  21. date = ""
  22. )
  23. convey.Convey("redisFKey", t, func(ctx convey.C) {
  24. p1 := redisFKey(mid, date)
  25. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  26. ctx.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestShareAddShare(t *testing.T) {
  31. var (
  32. c = context.TODO()
  33. mid = int64(1)
  34. aid = int64(1)
  35. ip = ""
  36. )
  37. convey.Convey("AddShare", t, func(ctx convey.C) {
  38. ok, err := d.AddShare(c, mid, aid, ip)
  39. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  40. ctx.So(err, convey.ShouldBeNil)
  41. ctx.So(ok, convey.ShouldNotBeNil)
  42. })
  43. })
  44. }
  45. func TestShareHadFirstShare(t *testing.T) {
  46. var (
  47. c = context.TODO()
  48. mid = int64(1)
  49. aid = int64(1)
  50. ip = ""
  51. )
  52. convey.Convey("HadFirstShare", t, func(ctx convey.C) {
  53. had, err := d.HadFirstShare(c, mid, aid, ip)
  54. ctx.Convey("Then err should be nil.had should not be nil.", func(ctx convey.C) {
  55. ctx.So(err, convey.ShouldBeNil)
  56. ctx.So(had, convey.ShouldNotBeNil)
  57. })
  58. })
  59. }