mc_seg_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/dm2/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestSetXMLSegCache(t *testing.T) {
  9. Convey("", t, func() {
  10. err := testDao.SetXMLSegCache(context.TODO(), model.SubTypeVideo, 1221, 1, 1, []byte("test"))
  11. So(err, ShouldBeNil)
  12. })
  13. }
  14. func TestXMLSegCache(t *testing.T) {
  15. Convey("", t, func() {
  16. _, err := testDao.XMLSegCache(context.TODO(), model.SubTypeVideo, 1221, 1, 1)
  17. So(err, ShouldBeNil)
  18. })
  19. }
  20. func TestDurationCache(t *testing.T) {
  21. var (
  22. oid int64 = 1508
  23. c = context.TODO()
  24. )
  25. Convey("", t, func() {
  26. _, err := testDao.DurationCache(c, oid)
  27. So(err, ShouldBeNil)
  28. })
  29. }
  30. func TestSetDurationCache(t *testing.T) {
  31. var (
  32. oid int64 = 1508
  33. duration int64 = 9031 * 1000
  34. c = context.TODO()
  35. )
  36. Convey("", t, func() {
  37. err := testDao.SetDurationCache(c, oid, duration)
  38. So(err, ShouldBeNil)
  39. })
  40. }
  41. func TestSetDMSegCache(t *testing.T) {
  42. Convey("set dm segment cache, error should be nil", t, func() {
  43. dmseg := new(model.DMSeg)
  44. dmseg.Elems = append(dmseg.Elems, &model.Elem{Content: "dm msg"})
  45. err := testDao.SetDMSegCache(c, 1, 1221, 1, 1, dmseg)
  46. So(err, ShouldBeNil)
  47. })
  48. }
  49. func TestDMSegCache(t *testing.T) {
  50. Convey("get dm segment cache", t, func() {
  51. dmseg, err := testDao.DMSegCache(c, 1, 1221, 1, 1)
  52. if err != nil {
  53. t.Fatal(err)
  54. }
  55. t.Logf("%+v", dmseg)
  56. })
  57. }