bgm_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestIncomeGetAvByBgm(t *testing.T) {
  8. convey.Convey("GetAvByBgm", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. sid = int64(1003)
  12. from = "2018-01-01"
  13. to = "2019-01-03"
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. Exec(c, "INSERT INTO bgm_income(sid,mid,date) VALUES(1003, 1000, '2018-05-01')")
  17. avs, err := d.GetAvByBgm(c, sid, from, to)
  18. ctx.Convey("Then err should be nil.avs should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(avs, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestIncomeGetBgmIncome(t *testing.T) {
  26. convey.Convey("GetBgmIncome", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. id = int64(0)
  30. query = ""
  31. from = "2018-01-02"
  32. to = "2018-01-03"
  33. limit = int(10)
  34. typ = int(0)
  35. )
  36. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  37. bgms, err := d.GetBgmIncome(c, id, query, from, to, limit, typ)
  38. ctx.Convey("Then err should be nil.bgms should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(bgms, convey.ShouldNotBeNil)
  41. })
  42. })
  43. })
  44. }