flow_test.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package service
  2. import (
  3. "context"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/main/videoup/model/archive"
  6. "testing"
  7. )
  8. func TestService_GetFlowsByOID(t *testing.T) {
  9. Convey("getFlowsByOID", t, WithService(func(s *Service) {
  10. var (
  11. c = context.TODO()
  12. oid = int64(2222)
  13. res []*archive.FlowData
  14. err error
  15. )
  16. res, err = s.getFlowsByOID(c, oid)
  17. t.Logf("res(%+v) error(%v)", res, err)
  18. So(err, ShouldBeNil)
  19. }))
  20. }
  21. func TestService_TxAddFlow(t *testing.T) {
  22. var (
  23. id int64
  24. err error
  25. )
  26. Convey("txAddFlow", t, WithService(func(s *Service) {
  27. c := context.TODO()
  28. tx, _ := s.arc.BeginTran(c)
  29. id, err = s.txAddFlow(tx, archive.PoolArcForbid, 1, archive.FlowGroupNoChannel, 421, "测试-频道禁止-添加")
  30. tx.Commit()
  31. So(id, ShouldBeGreaterThan, 0)
  32. So(err, ShouldBeNil)
  33. }))
  34. }
  35. func TestService_TxUpFlowState(t *testing.T) {
  36. var (
  37. err error
  38. )
  39. Convey("TxUpFlowState", t, WithService(func(s *Service) {
  40. c := context.TODO()
  41. f := &archive.FlowData{ID: 540, Pool: archive.PoolArcForbid, OID: 1, GroupID: archive.FlowGroupNoChannel}
  42. tx, _ := s.arc.BeginTran(c)
  43. err = s.txUpFlowState(tx, archive.FlowDelete, 421, f)
  44. tx.Commit()
  45. So(err, ShouldBeNil)
  46. }))
  47. }
  48. func TestService_txAddOrUpdateFlowState(t *testing.T) {
  49. Convey("txAddOrUpdateFlowState", t, WithService(func(s *Service) {
  50. var (
  51. c = context.TODO()
  52. group = archive.FlowGroupNoChannel
  53. pool = archive.PoolArcForbid
  54. err error
  55. diff string
  56. res *archive.FlowData
  57. )
  58. tx, _ := s.arc.BeginTran(c)
  59. res, diff, err = s.txAddOrUpdateFlowState(c, tx, 16, group, 421, pool, archive.FlowDelete, "新增测试啦")
  60. t.Logf("res(%+v) diff(%s) error(%v)", res, diff, err)
  61. So(err, ShouldBeNil)
  62. tx.Commit()
  63. tx, _ = s.arc.BeginTran(c)
  64. res, diff, err = s.txAddOrUpdateFlowState(c, tx, 16, group, 421, pool, archive.FlowOpen, "修改state测试啦")
  65. t.Logf("res(%+v) diff(%s) error(%v)", res, diff, err)
  66. So(err, ShouldBeNil)
  67. tx.Commit()
  68. }))
  69. }
  70. func TestService_HitFlowGroups(t *testing.T) {
  71. Convey("HitFlowGroups", t, WithService(func(s *Service) {
  72. var (
  73. c = context.TODO()
  74. oid = int64(2222)
  75. res map[string]int
  76. err error
  77. )
  78. res, err = s.HitFlowGroups(c, oid, []int8{})
  79. t.Logf("res(%+v) error(%v)", res, err)
  80. So(err, ShouldBeNil)
  81. res, err = s.HitFlowGroups(c, oid, []int8{archive.PoolUp})
  82. t.Logf("res(%+v) error(%v)", res, err)
  83. So(err, ShouldBeNil)
  84. }))
  85. }