mysql_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. pushmdl "go-common/app/service/main/push/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func Test_DelCallbacks(t *testing.T) {
  10. Convey("del callbacks", t, func() {
  11. loc, _ := time.LoadLocation("Local")
  12. tm := time.Date(2018, 1, 11, 18, 27, 03, 0, loc)
  13. rows, err := d.DelCallbacks(context.TODO(), tm, 1000)
  14. So(err, ShouldBeNil)
  15. t.Logf("del callback rows:%d", rows)
  16. })
  17. }
  18. func Test_DelTasks(t *testing.T) {
  19. Convey("del tasks", t, func() {
  20. loc, _ := time.LoadLocation("Local")
  21. tm := time.Date(2018, 4, 2, 16, 00, 00, 0, loc)
  22. rows, err := d.DelTasks(context.TODO(), tm, 1000)
  23. So(err, ShouldBeNil)
  24. t.Logf("del task rows:%d", rows)
  25. })
  26. }
  27. func Test_ReportLastID(t *testing.T) {
  28. Convey("get report latest id", t, func() {
  29. id, err := d.ReportLastID(context.TODO())
  30. So(err, ShouldBeNil)
  31. t.Logf("latest report id(%d)", id)
  32. })
  33. }
  34. func Test_TxTaskByStatus(t *testing.T) {
  35. Convey("tx task by status", t, func() {
  36. tx, _ := d.BeginTx(context.Background())
  37. _, err := d.TxTaskByStatus(tx, pushmdl.TaskStatusPrepared)
  38. So(err, ShouldBeNil)
  39. err = tx.Commit()
  40. So(err, ShouldBeNil)
  41. })
  42. }
  43. func Test_AddTask(t *testing.T) {
  44. Convey("tx add task", t, func() {
  45. err := d.AddTask(context.Background(), &pushmdl.Task{})
  46. So(err, ShouldBeNil)
  47. })
  48. }