redis_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestQusByType(t *testing.T) {
  8. convey.Convey("qusByType", t, func() {
  9. p1 := qusByType(0)
  10. convey.So(p1, convey.ShouldNotBeNil)
  11. })
  12. }
  13. func TestExtraQidByType(t *testing.T) {
  14. convey.Convey("extraQidByType", t, func() {
  15. p1 := extraQidByType(0)
  16. convey.So(p1, convey.ShouldNotBeNil)
  17. })
  18. }
  19. func TestDaopingRedis(t *testing.T) {
  20. convey.Convey("pingRedis", t, func() {
  21. err := d.pingRedis(context.Background())
  22. convey.So(err, convey.ShouldBeNil)
  23. })
  24. }
  25. func TestDaoSetQids(t *testing.T) {
  26. convey.Convey("SetQids", t, func() {
  27. err := d.SetQids(context.Background(), []int64{1, 2, 3}, 0)
  28. convey.So(err, convey.ShouldBeNil)
  29. })
  30. convey.Convey("QidByType", t, func() {
  31. ids, err := d.QidByType(context.Background(), 0, 3)
  32. convey.So(err, convey.ShouldBeNil)
  33. convey.So(ids, convey.ShouldNotBeNil)
  34. })
  35. }
  36. func TestDaoSetExtraQids(t *testing.T) {
  37. convey.Convey("SetExtraQids", t, func() {
  38. err := d.SetExtraQids(context.Background(), []int64{1, 2, 3}, 0)
  39. convey.So(err, convey.ShouldBeNil)
  40. })
  41. convey.Convey("ExtraQidByType", t, func() {
  42. ids, err := d.ExtraQidByType(context.Background(), 0, 2)
  43. convey.So(err, convey.ShouldBeNil)
  44. convey.So(ids, convey.ShouldNotBeNil)
  45. })
  46. convey.Convey("DelQidsCache", t, func() {
  47. err := d.DelQidsCache(context.Background(), 0)
  48. convey.So(err, convey.ShouldBeNil)
  49. })
  50. }
  51. func TestDaoDelExtraQidsCache(t *testing.T) {
  52. convey.Convey("DelExtraQidsCache", t, func() {
  53. err := d.DelExtraQidsCache(context.Background(), 0)
  54. convey.So(err, convey.ShouldBeNil)
  55. })
  56. }