memcache_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. var (
  8. biz = int64(1)
  9. uuid = "uuid"
  10. )
  11. func TestDaopingMC(t *testing.T) {
  12. convey.Convey("pingMC", t, func(ctx convey.C) {
  13. err := d.pingMC(context.Background())
  14. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. })
  17. })
  18. }
  19. func addUUIDCache() error {
  20. return d.AddUUIDCache(context.Background(), biz, uuid)
  21. }
  22. func TestDaoExistsUUIDCache(t *testing.T) {
  23. addUUIDCache()
  24. convey.Convey("ExistsUUIDCache", t, func(ctx convey.C) {
  25. exist, err := d.ExistsUUIDCache(context.Background(), biz, uuid)
  26. ctx.Convey("Then err should be nil.exist should not be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(exist, convey.ShouldNotBeNil)
  29. })
  30. })
  31. }
  32. func TestDaoAddUUIDCache(t *testing.T) {
  33. convey.Convey("AddUUIDCache", t, func(ctx convey.C) {
  34. err := addUUIDCache()
  35. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  36. ctx.So(err, convey.ShouldBeNil)
  37. })
  38. })
  39. }
  40. func TestDaoDelUUIDCache(t *testing.T) {
  41. addUUIDCache()
  42. convey.Convey("DelUUIDCache", t, func(ctx convey.C) {
  43. err := d.DelUUIDCache(context.Background(), biz, uuid)
  44. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. }