redis_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package archive
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestArchivelockKey(t *testing.T) {
  8. var (
  9. aid = int64(0)
  10. )
  11. convey.Convey("lockKey", t, func(ctx convey.C) {
  12. p1 := lockKey(aid)
  13. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  14. ctx.So(p1, convey.ShouldNotBeNil)
  15. })
  16. })
  17. }
  18. func TestArchiveGetVideoJam(t *testing.T) {
  19. var (
  20. c = context.Background()
  21. )
  22. convey.Convey("GetVideoJam", t, func(ctx convey.C) {
  23. seconds, err := d.GetVideoJam(c)
  24. ctx.Convey("Then err should be nil.seconds should not be nil.", func(ctx convey.C) {
  25. ctx.So(err, convey.ShouldBeNil)
  26. ctx.So(seconds, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestArchiveSetNXLock(t *testing.T) {
  31. var (
  32. c = context.Background()
  33. aid = int64(0)
  34. times = int64(0)
  35. )
  36. convey.Convey("SetNXLock", t, func(ctx convey.C) {
  37. res, err := d.SetNXLock(c, aid, times)
  38. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(res, convey.ShouldNotBeNil)
  41. })
  42. })
  43. }
  44. func TestArchiveDelLock(t *testing.T) {
  45. var (
  46. c = context.Background()
  47. aid = int64(0)
  48. )
  49. convey.Convey("DelLock", t, func(ctx convey.C) {
  50. err := d.DelLock(c, aid)
  51. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldBeNil)
  53. })
  54. })
  55. }