redis_test.go 718 B

123456789101112131415161718192021222324252627282930313233343536
  1. package databus
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDatabusLock(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. key = ""
  11. ttl = int(0)
  12. )
  13. convey.Convey("Lock", t, func(ctx convey.C) {
  14. gotLock, err := d.Lock(c, key, ttl)
  15. ctx.Convey("Then err should be nil.gotLock should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(gotLock, convey.ShouldNotBeNil)
  18. })
  19. })
  20. }
  21. func TestDatabusUnLock(t *testing.T) {
  22. var (
  23. c = context.TODO()
  24. key = ""
  25. )
  26. convey.Convey("UnLock", t, func(ctx convey.C) {
  27. err := d.UnLock(c, key)
  28. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. })
  31. })
  32. }