retry_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. "go-common/app/job/main/videoup-report/model/archive"
  8. "go-common/app/job/main/videoup-report/model/email"
  9. )
  10. var (
  11. aid = a.ID
  12. action = email.RetryActionReply
  13. flags = archive.ReplyOn
  14. flagA = archive.ReplyOff
  15. )
  16. func TestServiceaddRetry(t *testing.T) {
  17. var (
  18. c = context.Background()
  19. )
  20. convey.Convey("addRetry", t, func(ctx convey.C) {
  21. err := s.addRetry(c, aid, action, flags, flagA)
  22. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  23. ctx.So(err, convey.ShouldBeNil)
  24. })
  25. })
  26. }
  27. func TestServiceremoveRetry(t *testing.T) {
  28. var (
  29. c = context.Background()
  30. )
  31. TestServiceaddRetry(t)
  32. convey.Convey("removeRetry", t, func(ctx convey.C) {
  33. err := s.removeRetry(c, aid, action)
  34. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. })
  37. })
  38. }
  39. func TestServiceretryProc(t *testing.T) {
  40. convey.Convey("retryProc", t, func(ctx convey.C) {
  41. go func() {
  42. time.Sleep(1 * time.Second)
  43. s.closed = true
  44. }()
  45. s.retryProc()
  46. ctx.Convey("No return values", func(ctx convey.C) {
  47. })
  48. })
  49. }