cache_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaocacheSFstreamFullInfo(t *testing.T) {
  8. convey.Convey("cacheSFstreamFullInfo", t, func(ctx convey.C) {
  9. var (
  10. id = int64(11891462)
  11. sname = ""
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := d.cacheSFstreamFullInfo(id, sname)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaocacheSFstreamRIDByName(t *testing.T) {
  22. convey.Convey("cacheSFstreamRIDByName", t, func(ctx convey.C) {
  23. var (
  24. sname = "live_19148701_6447624"
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. p1 := d.cacheSFstreamRIDByName(sname)
  28. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  29. ctx.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaoStreamFullInfo(t *testing.T) {
  35. convey.Convey("StreamFullInfo", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. rid = int64(11891462)
  39. sname = ""
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. res, err := d.StreamFullInfo(c, rid, sname)
  43. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. ctx.So(res, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoOriginUpStreamInfo(t *testing.T) {
  51. convey.Convey("OriginUpStreamInfo", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. rid = int64(11891462)
  55. )
  56. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  57. sname, origin, err := d.OriginUpStreamInfo(c, rid)
  58. ctx.Convey("Then err should be nil.sname,origin should not be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. ctx.So(origin, convey.ShouldNotBeNil)
  61. ctx.So(sname, convey.ShouldNotBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoOriginUpStreamInfoBySName(t *testing.T) {
  67. convey.Convey("OriginUpStreamInfoBySName", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. sname = "live_19148701_6447624"
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. rid, origin, err := d.OriginUpStreamInfoBySName(c, sname)
  74. ctx.Convey("Then err should be nil.rid,origin should not be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. ctx.So(origin, convey.ShouldNotBeNil)
  77. ctx.So(rid, convey.ShouldNotBeNil)
  78. })
  79. })
  80. })
  81. }
  82. func TestDaoStreamRIDByName(t *testing.T) {
  83. convey.Convey("StreamRIDByName", t, func(ctx convey.C) {
  84. var (
  85. c = context.Background()
  86. sname = "live_19148701_6447624"
  87. )
  88. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  89. p1, err := d.StreamRIDByName(c, sname)
  90. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  91. ctx.So(err, convey.ShouldBeNil)
  92. ctx.So(p1, convey.ShouldNotBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoMultiStreamInfo(t *testing.T) {
  98. convey.Convey("MultiStreamInfo", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. rids = []int64{11891462}
  102. )
  103. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  104. res, err := d.MultiStreamInfo(c, rids)
  105. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  106. ctx.So(err, convey.ShouldBeNil)
  107. ctx.So(res, convey.ShouldNotBeNil)
  108. })
  109. })
  110. })
  111. }