task_db_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAssignTask(t *testing.T) {
  9. convey.Convey("AssignTask", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. task = task1
  13. )
  14. task.AdminID = 1
  15. task.UID = 1
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. rows, err := d.AssignTask(c, task)
  18. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(rows, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoQueryTask(t *testing.T) {
  26. convey.Convey("QueryTask", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. state = int8(0)
  30. mtime = time.Now()
  31. id = int64(0)
  32. limit = int64(1000)
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. tasks, lastid, err := d.QueryTask(c, state, mtime, id, limit)
  36. ctx.Convey("Then err should be nil.tasks,lastid should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(lastid, convey.ShouldNotBeNil)
  39. ctx.So(tasks, convey.ShouldNotBeNil)
  40. })
  41. })
  42. })
  43. }
  44. func TestDaoSetWeightDB(t *testing.T) {
  45. convey.Convey("SetWeightDB", t, func(ctx convey.C) {
  46. var (
  47. c = context.Background()
  48. taskid = int64(1)
  49. weight = int64(10)
  50. )
  51. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  52. rows, err := d.SetWeightDB(c, taskid, weight)
  53. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. ctx.So(rows, convey.ShouldNotBeNil)
  56. })
  57. })
  58. })
  59. }