pgc_auth_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package cms
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/interface/main/tv/model"
  6. "testing"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestCmsSeaCacheKey(t *testing.T) {
  10. var (
  11. sid = int64(0)
  12. )
  13. convey.Convey("SeaCacheKey", t, func(c convey.C) {
  14. p1 := d.SeaCacheKey(sid)
  15. c.Convey("Then p1 should not be nil.", func(c convey.C) {
  16. c.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. }
  20. func TestCmsEPCacheKey(t *testing.T) {
  21. var (
  22. epid = int64(0)
  23. )
  24. convey.Convey("EPCacheKey", t, func(c convey.C) {
  25. p1 := d.EPCacheKey(epid)
  26. c.Convey("Then p1 should not be nil.", func(c convey.C) {
  27. c.So(p1, convey.ShouldNotBeNil)
  28. })
  29. })
  30. }
  31. func TestCmsGetSeasonCache(t *testing.T) {
  32. var (
  33. ctx = context.Background()
  34. sid = int64(0)
  35. )
  36. convey.Convey("GetSeasonCache", t, func(c convey.C) {
  37. s, err := d.GetSeasonCache(ctx, sid)
  38. c.Convey("Then err should be nil.s should not be nil.", func(c convey.C) {
  39. c.So(err, convey.ShouldBeNil)
  40. c.So(s, convey.ShouldNotBeNil)
  41. })
  42. })
  43. }
  44. func TestCmsGetEPCache(t *testing.T) {
  45. var (
  46. ctx = context.Background()
  47. epid = int64(0)
  48. )
  49. convey.Convey("GetEPCache", t, func(c convey.C) {
  50. ep, err := d.GetEPCache(ctx, epid)
  51. c.Convey("Then err should be nil.ep should not be nil.", func(c convey.C) {
  52. c.So(err, convey.ShouldBeNil)
  53. c.So(ep, convey.ShouldNotBeNil)
  54. })
  55. })
  56. }
  57. func TestCmsAddSnAuthCache(t *testing.T) {
  58. var (
  59. ctx = context.Background()
  60. s = &model.SnAuth{}
  61. )
  62. convey.Convey("AddSnAuthCache", t, func(c convey.C) {
  63. err := d.AddSnAuthCache(ctx, s)
  64. c.Convey("Then err should be nil.", func(c convey.C) {
  65. c.So(err, convey.ShouldBeNil)
  66. })
  67. })
  68. }
  69. func TestCmsAddEpAuthCache(t *testing.T) {
  70. var (
  71. ctx = context.Background()
  72. ep = &model.EpAuth{}
  73. )
  74. convey.Convey("AddEpAuthCache", t, func(c convey.C) {
  75. err := d.AddEpAuthCache(ctx, ep)
  76. c.Convey("Then err should be nil.", func(c convey.C) {
  77. c.So(err, convey.ShouldBeNil)
  78. })
  79. })
  80. }
  81. func TestCmssnAuthCache(t *testing.T) {
  82. var (
  83. ctx = context.Background()
  84. )
  85. convey.Convey("snAuthCache", t, func(c convey.C) {
  86. sids, errPick := pickIDs(d.db, _pickSids)
  87. if errPick != nil || len(sids) == 0 {
  88. fmt.Println("Empty sids ", errPick)
  89. return
  90. }
  91. cached, missed, err := d.snAuthCache(ctx, sids)
  92. c.Convey("Then err should be nil.cached,missed should not be nil.", func(c convey.C) {
  93. c.So(err, convey.ShouldBeNil)
  94. c.So(len(missed)+len(cached), convey.ShouldBeGreaterThan, 0)
  95. })
  96. })
  97. }
  98. func TestCmsSnAuth(t *testing.T) {
  99. var (
  100. ctx = context.Background()
  101. sid = int64(0)
  102. )
  103. convey.Convey("SnAuth", t, func(c convey.C) {
  104. sn, err := d.SnAuth(ctx, sid)
  105. c.Convey("Then err should be nil.sn should not be nil.", func(c convey.C) {
  106. c.So(err, convey.ShouldBeNil)
  107. c.So(sn, convey.ShouldNotBeNil)
  108. })
  109. })
  110. }
  111. func TestCmsEpAuth(t *testing.T) {
  112. var (
  113. ctx = context.Background()
  114. epid = int64(0)
  115. )
  116. convey.Convey("EpAuth", t, func(c convey.C) {
  117. ep, err := d.EpAuth(ctx, epid)
  118. c.Convey("Then err should be nil.ep should not be nil.", func(c convey.C) {
  119. c.So(err, convey.ShouldBeNil)
  120. c.So(ep, convey.ShouldNotBeNil)
  121. })
  122. })
  123. }