backup-stream_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 TestDaoGetBackupStreamByRoomID(t *testing.T) {
  9. convey.Convey("GetBackupStreamByRoomID", t, func(ctx convey.C) {
  10. var (
  11. ctx2 = context.Background()
  12. rid = int64(11891462)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. infos, err := d.GetBackupStreamByRoomID(ctx2, rid)
  16. ctx.Convey("Then err should be nil.infos should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(infos, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoCreateBackupStream(t *testing.T) {
  24. convey.Convey("CreateBackupStream", t, func(ctx convey.C) {
  25. var (
  26. ctx2 = context.Background()
  27. bs = &model.BackupStream{
  28. RoomID: 66666,
  29. }
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. p1, err := d.CreateBackupStream(ctx2, bs)
  33. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(p1, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoGetBackupStreamByStreamName(t *testing.T) {
  41. convey.Convey("GetBackupStreamByStreamName", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. sn = "live_1511284_bs_7317941"
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. p1, err := d.GetBackupStreamByStreamName(c, sn)
  48. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(p1, convey.ShouldNotBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestDaoSetBackupStreamStreamingStatus(t *testing.T) {
  56. convey.Convey("SetBackupStreamStreamingStatus", t, func(ctx convey.C) {
  57. var (
  58. c = context.Background()
  59. p = &model.StreamingNotifyParam{
  60. SRC: "bvc",
  61. Type: "0",
  62. StreamName: "live_1511284_bs_7317941",
  63. }
  64. bs = &model.BackupStream{
  65. OriginUpstream: 1,
  66. StreamName: "live_1511284_bs_7317941",
  67. }
  68. open bool
  69. )
  70. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  71. p1, err := d.SetBackupStreamStreamingStatus(c, p, bs, open)
  72. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. ctx.So(p1, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }