databus_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package ugc
  2. import (
  3. "fmt"
  4. "testing"
  5. "go-common/app/service/main/archive/api"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDao_UpInList(t *testing.T) {
  9. Convey("TestDao_UpInList", t, WithDao(func(d *Dao) {
  10. res, err := d.UpInList(ctx, 27515615)
  11. So(err, ShouldBeNil)
  12. So(res, ShouldBeGreaterThan, 0)
  13. fmt.Println(res)
  14. res2, err2 := d.UpInList(ctx, 100997637777)
  15. So(err2, ShouldBeNil)
  16. So(res2, ShouldEqual, 0)
  17. }))
  18. }
  19. func TestDao_PickVideos(t *testing.T) {
  20. Convey("TestDao_PickVideos", t, WithDao(func(d *Dao) {
  21. res, err := d.PickVideos(ctx, 10099763)
  22. So(err, ShouldBeNil)
  23. So(len(res), ShouldBeGreaterThan, 0)
  24. for _, v := range res {
  25. fmt.Println(v)
  26. }
  27. }))
  28. }
  29. func TestDao_InsertVideos(t *testing.T) {
  30. Convey("TestDao_InsertVideos", t, WithDao(func(d *Dao) {
  31. tx, err := d.BeginTran(ctx)
  32. So(err, ShouldBeNil)
  33. err = d.TxAddVideos(tx, []*api.Page{
  34. {
  35. Cid: 10126229,
  36. Part: "test",
  37. Duration: 2333,
  38. Desc: "test",
  39. Page: 999,
  40. },
  41. }, 10098693)
  42. tx.Commit()
  43. So(err, ShouldBeNil)
  44. }))
  45. }