lock_test.go 865 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoLock(t *testing.T) {
  8. convey.Convey("Lock", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. key = "LOCK:ORDER:12345"
  12. val = "123456789"
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. err := d.Lock(c, key, val)
  16. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoUnlock(t *testing.T) {
  23. convey.Convey("Unlock", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. key = "LOCK:ORDER:12345"
  27. val = "123456789"
  28. )
  29. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  30. err := d.Unlock(c, key, val)
  31. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. })
  34. })
  35. })
  36. }