viewer_test.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package data
  2. import (
  3. "context"
  4. "go-common/app/admin/main/up/model/datamodel"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDataViewerBase(t *testing.T) {
  10. convey.Convey("ViewerBase", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. mid = int64(0)
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. res, err := s.ViewerBase(c, mid)
  17. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(res, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDataViewerArea(t *testing.T) {
  25. convey.Convey("ViewerArea", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. mid = int64(0)
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. res, err := s.ViewerArea(c, mid)
  32. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(res, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDataCacheTrend(t *testing.T) {
  40. convey.Convey("CacheTrend", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. mid = int64(0)
  44. )
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. res, err := s.CacheTrend(c, mid)
  47. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. ctx.So(res, convey.ShouldNotBeNil)
  50. })
  51. })
  52. })
  53. }
  54. func TestDataGetTags(t *testing.T) {
  55. convey.Convey("GetTags", t, func(ctx convey.C) {
  56. var (
  57. c = context.Background()
  58. ids = int64(0)
  59. )
  60. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  61. result := s.GetTags(c, ids)
  62. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  63. ctx.So(result, convey.ShouldNotBeNil)
  64. })
  65. })
  66. })
  67. }
  68. func TestDataviewerTrend(t *testing.T) {
  69. convey.Convey("viewerTrend", t, func(ctx convey.C) {
  70. var (
  71. c = context.Background()
  72. mid = int64(0)
  73. dt = time.Now()
  74. )
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. res, err := s.viewerTrend(c, mid, dt)
  77. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(res, convey.ShouldNotBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDataGetUpViewInfo(t *testing.T) {
  85. convey.Convey("GetUpViewInfo", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. arg = &datamodel.GetUpViewInfoArg{}
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. result, err := s.GetUpViewInfo(c, arg)
  92. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(result, convey.ShouldNotBeNil)
  95. })
  96. })
  97. })
  98. }
  99. func TestDataGetViewData(t *testing.T) {
  100. convey.Convey("GetViewData", t, func(ctx convey.C) {
  101. var (
  102. c = context.Background()
  103. mid = int64(0)
  104. )
  105. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  106. result, err := s.GetViewData(c, mid)
  107. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  108. ctx.So(err, convey.ShouldBeNil)
  109. ctx.So(result, convey.ShouldNotBeNil)
  110. })
  111. })
  112. })
  113. }
  114. func TestDataGetFansSummary(t *testing.T) {
  115. convey.Convey("GetFansSummary", t, func(ctx convey.C) {
  116. var (
  117. c = context.Background()
  118. arg = &datamodel.GetFansSummaryArg{}
  119. )
  120. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  121. result, err := s.GetFansSummary(c, arg)
  122. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  123. ctx.So(err, convey.ShouldBeNil)
  124. ctx.So(result, convey.ShouldNotBeNil)
  125. })
  126. })
  127. })
  128. }
  129. func TestDataGetRelationFansDay(t *testing.T) {
  130. convey.Convey("GetRelationFansDay", t, func(ctx convey.C) {
  131. var (
  132. c = context.Background()
  133. arg = &datamodel.GetRelationFansHistoryArg{}
  134. )
  135. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  136. result, err := s.GetRelationFansDay(c, arg)
  137. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  138. ctx.So(err, convey.ShouldBeNil)
  139. ctx.So(result, convey.ShouldNotBeNil)
  140. })
  141. })
  142. })
  143. }