statistics_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/mcn/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestServiceArcTopDataStatistics(t *testing.T) {
  9. convey.Convey("ArcTopDataStatistics", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. arg = &model.McnGetRankReq{}
  13. )
  14. arg.SignID = 214
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. res, err := s.ArcTopDataStatistics(c, arg)
  17. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(res, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestServiceMcnsTotalDatas(t *testing.T) {
  25. convey.Convey("McnsTotalDatas", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. arg = &model.TotalMcnDataReq{Date: 1542211200}
  29. )
  30. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  31. res, err := s.McnsTotalDatas(c, arg)
  32. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(res, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestServicestatTypeRate(t *testing.T) {
  40. convey.Convey("statTypeRate", t, func(ctx convey.C) {
  41. var (
  42. dts = []*model.DataTypes{}
  43. total = int64(111)
  44. )
  45. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  46. statTypeRate(dts, total)
  47. ctx.Convey("No return values", func(ctx convey.C) {
  48. })
  49. })
  50. })
  51. }