up_rank_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package upcrmservice
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/up/model/upcrmmodel"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestUpcrmservicesortRankInfo(t *testing.T) {
  10. convey.Convey("sortRankInfo", t, func(ctx convey.C) {
  11. var (
  12. planets = []*upcrmmodel.UpRankInfo{}
  13. sortfunc sortRankFunc
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. sortRankInfo(planets, sortfunc)
  17. ctx.Convey("No return values", func(ctx convey.C) {
  18. })
  19. })
  20. })
  21. }
  22. func TestUpcrmservicesortByValueAsc(t *testing.T) {
  23. convey.Convey("sortByValueAsc", t, func(ctx convey.C) {
  24. var (
  25. p1 = &upcrmmodel.UpRankInfo{}
  26. p2 = &upcrmmodel.UpRankInfo{}
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. p1 := sortByValueAsc(p1, p2)
  30. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  31. ctx.So(p1, convey.ShouldNotBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestUpcrmservicesortByValueDesc(t *testing.T) {
  37. convey.Convey("sortByValueDesc", t, func(ctx convey.C) {
  38. var (
  39. p1 = &upcrmmodel.UpRankInfo{}
  40. p2 = &upcrmmodel.UpRankInfo{}
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. p1 := sortByValueDesc(p1, p2)
  44. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  45. ctx.So(p1, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestUpcrmservicerefreshUpRankDate(t *testing.T) {
  51. convey.Convey("refreshUpRankDate", t, func(ctx convey.C) {
  52. var (
  53. date = time.Now()
  54. )
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. s.refreshUpRankDate(date)
  57. ctx.Convey("No return values", func(ctx convey.C) {
  58. })
  59. })
  60. })
  61. }
  62. func TestUpcrmserviceUpRankQueryList(t *testing.T) {
  63. convey.Convey("UpRankQueryList", t, func(ctx convey.C) {
  64. var (
  65. c = context.Background()
  66. arg = &upcrmmodel.UpRankQueryArgs{}
  67. )
  68. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  69. result, err := s.UpRankQueryList(c, arg)
  70. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. ctx.So(result, convey.ShouldNotBeNil)
  73. })
  74. })
  75. })
  76. }