mysql_test.go 826 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. plmdl "go-common/app/interface/main/playlist/model"
  7. "go-common/app/job/main/playlist/model"
  8. xtime "go-common/library/time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestDao_Stat(t *testing.T) {
  12. Convey("test stat", t, WithDao(func(d *Dao) {
  13. pid := int64(41)
  14. res, err := d.Stat(context.TODO(), pid)
  15. So(err, ShouldBeNil)
  16. Printf("%+v", res)
  17. }))
  18. }
  19. func TestDao_Update(t *testing.T) {
  20. Convey("test update", t, WithDao(func(d *Dao) {
  21. var (
  22. pid int64 = 1
  23. aid int64 = 1
  24. view int64 = 2
  25. )
  26. arg := &model.StatM{Type: plmdl.PlDBusType, ID: pid, Aid: aid, Count: &view, Timestamp: xtime.Time(time.Now().Unix()), IP: ""}
  27. res, err := d.Update(context.TODO(), arg, model.ViewCountType)
  28. So(err, ShouldBeNil)
  29. So(res, ShouldNotBeEmpty)
  30. }))
  31. }