up_income_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_UpIncomeStatis(t *testing.T) {
  9. Convey("UpIncomeStatis", t, WithService(func(s *Service) {
  10. mids := []int64{}
  11. groupType := 1
  12. fromTime := time.Now().AddDate(0, -1, 0).Unix() * 1000
  13. toTime := time.Now().Unix() * 1000
  14. _, err := s.UpIncomeStatis(context.Background(), mids, 0, groupType, fromTime, toTime)
  15. So(err, ShouldBeNil)
  16. }))
  17. }
  18. func Test_GetUpIncome(t *testing.T) {
  19. Convey("GetUpIncome", t, WithService(func(s *Service) {
  20. mids := []int64{}
  21. fromTime := time.Now().AddDate(0, -1, 0)
  22. toTime := time.Now()
  23. query := formatUpQuery(mids, fromTime, toTime, "income")
  24. _, err := s.GetUpIncome(context.Background(), "up_income", "income", query)
  25. So(err, ShouldBeNil)
  26. }))
  27. }
  28. func BenchmarkUpIncomeStatis(b *testing.B) {
  29. for n := 0; n < b.N; n++ {
  30. mids := []int64{}
  31. groupType := 1
  32. fromTime := time.Now().AddDate(0, -1, 0).Unix() * 1000
  33. toTime := time.Now().Unix() * 1000
  34. s.UpIncomeStatis(context.Background(), mids, 0, groupType, fromTime, toTime)
  35. }
  36. }
  37. func BenchmarkGetUpIncome(b *testing.B) {
  38. for n := 0; n < b.N; n++ {
  39. mids := []int64{}
  40. fromTime := time.Now().AddDate(0, -1, 0)
  41. toTime := time.Now()
  42. query := formatUpQuery(mids, fromTime, toTime, "income")
  43. s.GetUpIncome(context.Background(), "up_income", "income", query)
  44. }
  45. }