redis_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package videoshot
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestVideoshothashKey(t *testing.T) {
  8. var (
  9. cid = int64(1)
  10. )
  11. convey.Convey("hashKey", t, func(ctx convey.C) {
  12. p1 := hashKey(cid)
  13. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  14. ctx.So(p1, convey.ShouldNotBeNil)
  15. })
  16. })
  17. }
  18. func TestVideoshotcache(t *testing.T) {
  19. var (
  20. c = context.TODO()
  21. cid = int64(1)
  22. )
  23. convey.Convey("cache", t, func(ctx convey.C) {
  24. count, ver, err := d.cache(c, cid)
  25. ctx.Convey("Then err should be nil.count,ver should not be nil.", func(ctx convey.C) {
  26. ctx.So(err, convey.ShouldBeNil)
  27. ctx.So(ver, convey.ShouldNotBeNil)
  28. ctx.So(count, convey.ShouldNotBeNil)
  29. })
  30. })
  31. }
  32. func TestVideoshotaddCache(t *testing.T) {
  33. var (
  34. c = context.TODO()
  35. cid = int64(1)
  36. ver = int(0)
  37. count = int(0)
  38. )
  39. convey.Convey("addCache", t, func(ctx convey.C) {
  40. err := d.addCache(c, cid, ver, count)
  41. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. }