task_test.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAddTask(t *testing.T) {
  8. convey.Convey("AddTask", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. mid = int64(2233)
  12. username = "yanjinbin"
  13. adminID = int64(479)
  14. logDate = "2018-11-28 20:19:09"
  15. contactEmail = "yanjinbin@qq.com"
  16. platform = int(1)
  17. sourceType = int(1)
  18. )
  19. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  20. d.AddTask(c, mid, username, adminID, logDate, contactEmail, platform, sourceType)
  21. ctx.Convey("Then err should be nil.lastInsertID should not be nil.", func(ctx convey.C) {
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoFindTask(t *testing.T) {
  27. convey.Convey("FindTask", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. mid = int64(0)
  31. state = int(0)
  32. )
  33. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  34. d.FindTask(c, mid, state)
  35. ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoQueryTaskInfoByIDSQL(t *testing.T) {
  41. convey.Convey("QueryTaskInfoByIDSQL", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. id = int64(0)
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. d.QueryTaskInfoByIDSQL(c, id)
  48. ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
  49. })
  50. })
  51. })
  52. }
  53. func TestDaoDeleteTask(t *testing.T) {
  54. convey.Convey("DeleteTask", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. taskID = int64(0)
  58. username = ""
  59. adminID = int64(0)
  60. )
  61. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  62. err := d.DeleteTask(c, taskID, username, adminID)
  63. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoUpdateTask(t *testing.T) {
  70. convey.Convey("UpdateTask", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. taskID = int64(0)
  74. state = int(0)
  75. updateStmt = ""
  76. )
  77. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  78. d.UpdateTask(c, taskID, state, updateStmt)
  79. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoQueryTask(t *testing.T) {
  85. convey.Convey("QueryTask", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. queryStmt = ""
  89. sort = ""
  90. offset = int(0)
  91. limit = int(0)
  92. )
  93. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  94. d.QueryTask(c, queryStmt, sort, offset, limit)
  95. ctx.Convey("Then err should be nil.tasks,count should not be nil.", func(ctx convey.C) {
  96. })
  97. })
  98. })
  99. }