main-stream_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/video/stream-mng/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoCreateNewStream(t *testing.T) {
  9. convey.Convey("CreateNewStream", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. stream = &model.MainStream{
  13. RoomID: 123456,
  14. StreamName: "tetststest",
  15. Key: "testtestetste",
  16. }
  17. )
  18. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  19. p1, err := d.CreateNewStream(c, stream)
  20. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.So(p1, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaoGetMainStreamFromDB(t *testing.T) {
  28. convey.Convey("GetMainStreamFromDB", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. roomID = int64(11891462)
  32. streamName = ""
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. p1, err := d.GetMainStreamFromDB(c, roomID, streamName)
  36. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(p1, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoChangeDefaultVendor(t *testing.T) {
  44. convey.Convey("ChangeDefaultVendor", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. roomID = int64(11891462)
  48. newVendor = int64(2)
  49. )
  50. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  51. err := d.ChangeDefaultVendor(c, roomID, newVendor)
  52. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoClearMainStreaming(t *testing.T) {
  59. convey.Convey("ClearMainStreaming", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. roomID = int64(11891462)
  63. options = int64(0)
  64. newoptions = int64(0)
  65. )
  66. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  67. err := d.ClearMainStreaming(c, roomID, newoptions, options)
  68. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. })
  71. })
  72. })
  73. }
  74. func TestDaoMainStreamNotify(t *testing.T) {
  75. convey.Convey("MainStreamNotify", t, func(ctx convey.C) {
  76. var (
  77. c = context.Background()
  78. roomID = int64(11891462)
  79. vendor = int64(2)
  80. isOpen bool
  81. isOrigin bool
  82. options = int64(0)
  83. newoptions = int64(0)
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. err := d.MainStreamNotify(c, roomID, vendor, isOpen, isOrigin, options, newoptions)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }