mysql_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. pushmdl "go-common/app/service/main/push/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoBusinesses(t *testing.T) {
  9. convey.Convey("Businesses", t, func(ctx convey.C) {
  10. res, err := d.Businesses(context.Background())
  11. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  12. ctx.So(err, convey.ShouldBeNil)
  13. ctx.So(res, convey.ShouldNotBeNil)
  14. })
  15. })
  16. }
  17. func addTask() (id int64, err error) {
  18. t := &pushmdl.Task{APPID: 1}
  19. return d.AddTask(context.Background(), t)
  20. }
  21. func TestDaoAddTask(t *testing.T) {
  22. convey.Convey("AddTask", t, func(ctx convey.C) {
  23. id, err := addTask()
  24. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  25. ctx.So(err, convey.ShouldBeNil)
  26. ctx.So(id, convey.ShouldBeGreaterThan, 0)
  27. })
  28. })
  29. }
  30. func TestDaoTask(t *testing.T) {
  31. id, _ := addTask()
  32. convey.Convey("Task", t, func(ctx convey.C) {
  33. no, err := d.Task(context.Background(), id)
  34. ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(no, convey.ShouldNotBeNil)
  37. })
  38. })
  39. }
  40. func TestDaoMaxSettingID(t *testing.T) {
  41. convey.Convey("MaxSettingID", t, func(ctx convey.C) {
  42. _, err := d.MaxSettingID(context.Background())
  43. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. })
  46. })
  47. }
  48. func TestDaoSettingsByRange(t *testing.T) {
  49. var (
  50. start = int64(0)
  51. end = int64(1000)
  52. )
  53. convey.Convey("SettingsByRange", t, func(ctx convey.C) {
  54. res, err := d.SettingsByRange(context.Background(), start, end)
  55. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldBeNil)
  57. ctx.So(res, convey.ShouldNotBeNil)
  58. })
  59. })
  60. }