redis_task_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoSetnxTaskJob(t *testing.T) {
  8. convey.Convey("SetnxTaskJob", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. value = ""
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. ok, err := testDao.SetnxTaskJob(c, value)
  15. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(ok, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoGetTaskJob(t *testing.T) {
  23. convey.Convey("GetTaskJob", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. testDao.GetTaskJob(c)
  29. })
  30. })
  31. }
  32. func TestDaoGetSetTaskJob(t *testing.T) {
  33. convey.Convey("GetSetTaskJob", t, func(ctx convey.C) {
  34. var (
  35. c = context.Background()
  36. value = ""
  37. )
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. old, err := testDao.GetSetTaskJob(c, value)
  40. ctx.Convey("Then err should be nil.old should not be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. ctx.So(old, convey.ShouldNotBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestDaoDelTaskJob(t *testing.T) {
  48. convey.Convey("DelTaskJob", t, func(ctx convey.C) {
  49. var (
  50. c = context.Background()
  51. )
  52. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  53. err := testDao.DelTaskJob(c)
  54. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  55. ctx.So(err, convey.ShouldBeNil)
  56. })
  57. })
  58. })
  59. }