redis_seg_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDMIDCache(t *testing.T) {
  8. var (
  9. tp int32 = 1
  10. oid int64 = 1508
  11. cnt int64 = 26
  12. num int64 = 1
  13. c = context.TODO()
  14. )
  15. Convey("", t, func() {
  16. _, err := testDao.DMIDCache(c, tp, oid, cnt, num, 100)
  17. So(err, ShouldBeNil)
  18. })
  19. }
  20. func TestAddDMIDCache(t *testing.T) {
  21. Convey("", t, func() {
  22. err := testDao.AddDMIDCache(c, 1, 1508, 26, 1, 1233333333333)
  23. So(err, ShouldBeNil)
  24. })
  25. }
  26. func TestIdxContentCacheV2(t *testing.T) {
  27. var (
  28. tp int32 = 1
  29. oid int64 = 1508
  30. c = context.TODO()
  31. dmids = []int64{2355015081, 2356915089}
  32. )
  33. Convey("", t, func() {
  34. elems, missed, err := testDao.IdxContentCacheV2(c, tp, oid, dmids)
  35. So(err, ShouldBeNil)
  36. t.Logf("missed dmid:%v", missed)
  37. t.Logf("elems:%+v", elems)
  38. })
  39. }
  40. func TestXMLToElem(t *testing.T) {
  41. Convey("convert xml tag to elem struct", t, func() {
  42. s := []byte(`<d p="1,1,1,1,11,111,11,1,23123123">弹幕内容</d>`)
  43. elem, err := testDao.xmlToElem(s)
  44. So(err, ShouldBeNil)
  45. t.Logf("%+v", elem)
  46. })
  47. }