refresh_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package upper
  2. import (
  3. "context"
  4. "testing"
  5. ugcMdl "go-common/app/job/main/tv/model/ugc"
  6. "fmt"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestUpperCountUP(t *testing.T) {
  10. var c = context.Background()
  11. convey.Convey("CountUP", t, func(ctx convey.C) {
  12. count, err := d.CountUP(c)
  13. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  14. ctx.So(err, convey.ShouldBeNil)
  15. ctx.So(count, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestUpperSendUpper(t *testing.T) {
  20. var (
  21. mid = int64(0)
  22. )
  23. convey.Convey("SendUpper", t, func(ctx convey.C) {
  24. err := d.SendUpper(context.Background(), mid)
  25. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  26. ctx.So(err, convey.ShouldBeNil)
  27. })
  28. })
  29. }
  30. func TestDao_SetUpperV(t *testing.T) {
  31. convey.Convey("TestDao_LoadUpMeta", t, WithDao(func(d *Dao) {
  32. var (
  33. query = "SELECT mid FROM ugc_uploader WHERE deleted = 0 LIMIT 1"
  34. upper = &ugcMdl.Upper{}
  35. )
  36. if err := d.DB.QueryRow(ctx, query).Scan(&upper.MID); err != nil || upper.MID == 0 {
  37. fmt.Println("DB Error ", err)
  38. return
  39. }
  40. req := &ugcMdl.ReqSetUp{
  41. Value: "test",
  42. MID: upper.MID,
  43. UpType: _upName,
  44. }
  45. oriUp, err2 := d.LoadUpMeta(ctx, req.MID)
  46. if err2 != nil || oriUp == nil {
  47. return
  48. }
  49. fmt.Println(req.MID)
  50. err := d.setUpperV(context.Background(), req, oriUp)
  51. convey.So(err, convey.ShouldBeNil)
  52. }))
  53. }
  54. func TestUpperImportUp(t *testing.T) {
  55. var (
  56. up = &ugcMdl.EasyUp{}
  57. )
  58. convey.Convey("ImportUp", t, func(ctx convey.C) {
  59. err := d.ImportUp(context.Background(), up)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. }