user_fan_test.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package dao
  2. import (
  3. "context"
  4. "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/service/bbq/user/internal/model"
  6. xtime "go-common/library/time"
  7. "testing"
  8. "time"
  9. )
  10. func TestDaoTxAddUserFan(t *testing.T) {
  11. convey.Convey("TxAddUserFan", t, func(ctx convey.C) {
  12. var (
  13. c = context.Background()
  14. mid = int64(88895104)
  15. fanMid = int64(88895105)
  16. )
  17. tx, _ := d.BeginTran(c)
  18. defer func() {
  19. tx.Rollback()
  20. }()
  21. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  22. num, err := d.TxAddUserFan(tx, mid, fanMid)
  23. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  24. ctx.So(err, convey.ShouldBeNil)
  25. ctx.So(num, convey.ShouldNotBeNil)
  26. })
  27. })
  28. })
  29. }
  30. func TestDaoTxCancelUserFan(t *testing.T) {
  31. convey.Convey("TxCancelUserFan", t, func(ctx convey.C) {
  32. var (
  33. c = context.Background()
  34. mid = int64(88895104)
  35. fanMid = int64(88895105)
  36. )
  37. tx, _ := d.BeginTran(c)
  38. defer func() {
  39. tx.Rollback()
  40. }()
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. num, err := d.TxCancelUserFan(tx, mid, fanMid)
  43. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. ctx.So(num, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoIsFan(t *testing.T) {
  51. convey.Convey("IsFan", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. mid = int64(88895104)
  55. candidateMIDs = []int64{88895105}
  56. )
  57. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  58. MIDMap := d.IsFan(c, mid, candidateMIDs)
  59. ctx.Convey("Then MIDMap should not be nil.", func(ctx convey.C) {
  60. ctx.So(MIDMap, convey.ShouldNotBeNil)
  61. })
  62. })
  63. })
  64. }
  65. func TestDaoFetchPartFanList(t *testing.T) {
  66. convey.Convey("FetchPartFanList", t, func(ctx convey.C) {
  67. var (
  68. c = context.Background()
  69. mid = int64(88895104)
  70. cursor model.CursorValue
  71. size = int(10)
  72. )
  73. cursor.CursorID = model.MaxInt64
  74. cursor.CursorTime = xtime.Time(time.Now().Unix())
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. MID2IDMap, followedMIDs, err := d.FetchPartFanList(c, mid, cursor, size)
  77. ctx.Convey("Then err should be nil.MID2IDMap,followedMIDs should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(followedMIDs, convey.ShouldNotBeNil)
  80. ctx.So(MID2IDMap, convey.ShouldNotBeNil)
  81. })
  82. })
  83. })
  84. }