redis_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package stat
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestStatipBanKey(t *testing.T) {
  8. convey.Convey("ipBanKey", t, func(convCtx convey.C) {
  9. var (
  10. id = int64(0)
  11. ip = ""
  12. )
  13. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  14. key := ipBanKey(id, ip)
  15. convCtx.Convey("Then key should not be nil.", func(convCtx convey.C) {
  16. convCtx.So(key, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestStatbuvidBanKey(t *testing.T) {
  22. convey.Convey("buvidBanKey", t, func(convCtx convey.C) {
  23. var (
  24. id = int64(0)
  25. mid = int64(0)
  26. ip = ""
  27. buvid = ""
  28. )
  29. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  30. key := buvidBanKey(id, mid, ip, buvid)
  31. convCtx.Convey("Then key should not be nil.", func(convCtx convey.C) {
  32. convCtx.So(key, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestStatIPBan(t *testing.T) {
  38. convey.Convey("IPBan", t, func(convCtx convey.C) {
  39. var (
  40. c = context.Background()
  41. id = int64(0)
  42. ip = ""
  43. )
  44. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  45. ban := d.IPBan(c, id, ip)
  46. convCtx.Convey("Then ban should not be nil.", func(convCtx convey.C) {
  47. convCtx.So(ban, convey.ShouldNotBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestStatBuvidBan(t *testing.T) {
  53. convey.Convey("BuvidBan", t, func(convCtx convey.C) {
  54. var (
  55. c = context.Background()
  56. id = int64(0)
  57. mid = int64(0)
  58. buvid = ""
  59. ip = ""
  60. )
  61. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  62. ban := d.BuvidBan(c, id, mid, ip, buvid)
  63. convCtx.Convey("Then ban should not be nil.", func(convCtx convey.C) {
  64. convCtx.So(ban, convey.ShouldNotBeNil)
  65. })
  66. })
  67. })
  68. }