query_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/search/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoQueryConf(t *testing.T) {
  9. convey.Convey("QueryConf", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. res, err := d.QueryConf(c)
  15. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(res, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoQueryBasic(t *testing.T) {
  23. convey.Convey("QueryBasic", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. sp = &model.QueryParams{
  27. QueryBody: &model.QueryBody{},
  28. }
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. mixedQuery, qbDebug := d.QueryBasic(c, sp)
  32. ctx.Convey("Then mixedQuery,qbDebug should not be nil.", func(ctx convey.C) {
  33. ctx.So(qbDebug, convey.ShouldNotBeNil)
  34. ctx.So(mixedQuery, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoqueryBasicRange(t *testing.T) {
  40. convey.Convey("queryBasicRange", t, func(ctx convey.C) {
  41. var (
  42. rangeMap map[string]string
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. rangeQuery, err := d.queryBasicRange(rangeMap)
  46. ctx.Convey("Then err should be nil.rangeQuery should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. ctx.So(rangeQuery, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestDaoqueryBasicLike(t *testing.T) {
  54. convey.Convey("queryBasicLike", t, func(ctx convey.C) {
  55. var (
  56. likeMap = []model.QueryBodyWhereLike{}
  57. business = ""
  58. )
  59. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  60. _, err := d.queryBasicLike(likeMap, business)
  61. ctx.Convey("Then err should be nil.likeQuery should not be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. //ctx.So(likeQuery, convey.ShouldNotBeNil)
  64. })
  65. })
  66. })
  67. }
  68. func TestDaoScroll(t *testing.T) {
  69. convey.Convey("Scroll", t, func(ctx convey.C) {
  70. var (
  71. c = context.Background()
  72. sp = &model.QueryParams{
  73. QueryBody: &model.QueryBody{},
  74. AppIDConf: &model.QueryConfDetail{
  75. ESCluster: "",
  76. },
  77. }
  78. )
  79. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  80. //res, debug, err :=
  81. d.Scroll(c, sp)
  82. ctx.Convey("Then err should be nil.res,debug should not be nil.", func(ctx convey.C) {
  83. //ctx.So(err, convey.ShouldBeNil)
  84. //ctx.So(debug, convey.ShouldNotBeNil)
  85. //ctx.So(res, convey.ShouldNotBeNil)
  86. })
  87. })
  88. })
  89. }