searcher_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package dao
  2. import (
  3. "go-common/app/service/main/riot-search/model"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoSearchIDOnly(t *testing.T) {
  8. convey.Convey("SearchIDOnly", t, func(ctx convey.C) {
  9. var (
  10. arg1 = &model.RiotSearchReq{}
  11. arg2 = &model.RiotSearchReq{Keyword: "test", IDs: []uint64{1}}
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := d.SearchIDOnly(arg1)
  15. ctx.Convey("Then p1 should be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldBeNil)
  17. })
  18. p2 := d.SearchIDOnly(arg2)
  19. ctx.Convey("Then p2 should not be nil.", func(ctx convey.C) {
  20. ctx.So(p2, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoSearch(t *testing.T) {
  26. convey.Convey("Search", t, func(ctx convey.C) {
  27. var (
  28. arg1 = &model.RiotSearchReq{}
  29. arg2 = &model.RiotSearchReq{Keyword: "test", IDs: []uint64{1}}
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. p1 := d.Search(arg1)
  33. ctx.Convey("Then p1 should be nil.", func(ctx convey.C) {
  34. ctx.So(p1, convey.ShouldBeNil)
  35. })
  36. p2 := d.Search(arg2)
  37. ctx.Convey("Then p2 should not be nil.", func(ctx convey.C) {
  38. ctx.So(p2, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoHas(t *testing.T) {
  44. convey.Convey("Search", t, func(ctx convey.C) {
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. p1 := d.Has(1)
  47. ctx.Convey("Then p1 should be false.", func(ctx convey.C) {
  48. ctx.So(p1, convey.ShouldBeFalse)
  49. })
  50. })
  51. })
  52. }