archive_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/ecode"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. "gopkg.in/h2non/gock.v1"
  8. )
  9. func TestDaoArcAppeal(t *testing.T) {
  10. convey.Convey("ArcAppeal", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. mid = int64(2222)
  14. business = int(1)
  15. )
  16. data := map[string]string{"tid": "27", "oid": "222", "description": "test111"}
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. err := d.ArcAppeal(c, mid, data, business)
  19. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoAppealTags(t *testing.T) {
  26. convey.Convey("AppealTags", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. business = int(1)
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. rs, err := d.AppealTags(c, business)
  33. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(rs, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoRelatedAids(t *testing.T) {
  41. convey.Convey("RelatedAids", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. aid = int64(9912124)
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. defer gock.OffAll()
  48. httpMock("GET", d.relatedURL).Reply(200).JSON(`{"data":[{"key":"33817773","value":"14536406,25731794"}]}`)
  49. aids, err := d.RelatedAids(c, aid)
  50. ctx.Convey("Then err should be nil.aids should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(aids, convey.ShouldNotBeNil)
  53. ctx.Printf("%+v", aids)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaokeyArcAppealLimit(t *testing.T) {
  59. convey.Convey("keyArcAppealLimit", t, func(ctx convey.C) {
  60. var (
  61. mid = int64(0)
  62. aid = int64(0)
  63. )
  64. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  65. p1 := keyArcAppealLimit(mid, aid)
  66. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  67. ctx.So(p1, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }
  72. func TestDaoSetArcAppealCache(t *testing.T) {
  73. convey.Convey("SetArcAppealCache", t, func(ctx convey.C) {
  74. var (
  75. c = context.Background()
  76. mid = int64(2222)
  77. aid = int64(2222)
  78. )
  79. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  80. err := d.SetArcAppealCache(c, mid, aid)
  81. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  82. ctx.So(err, convey.ShouldBeNil)
  83. })
  84. })
  85. })
  86. }
  87. func TestDaoArcAppealCache(t *testing.T) {
  88. convey.Convey("ArcAppealCache", t, func(ctx convey.C) {
  89. var (
  90. c = context.Background()
  91. mid = int64(2222)
  92. aid = int64(2222)
  93. )
  94. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  95. err := d.ArcAppealCache(c, mid, aid)
  96. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldEqual, ecode.ArcAppealLimit)
  98. })
  99. })
  100. })
  101. }
  102. func TestDaoSpecial(t *testing.T) {
  103. convey.Convey("Special", t, func(convCtx convey.C) {
  104. var (
  105. c = context.Background()
  106. )
  107. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  108. midsM, err := d.Special(c)
  109. convCtx.Convey("Then err should be nil.midsM should not be nil.", func(convCtx convey.C) {
  110. convCtx.So(err, convey.ShouldBeNil)
  111. convCtx.So(midsM, convey.ShouldNotBeNil)
  112. })
  113. })
  114. })
  115. }