up_income_stat_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestIncomeUpIncomeStat(t *testing.T) {
  8. convey.Convey("UpIncomeStat", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. id = int64(0)
  12. limit = int64(100)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. d.db.Exec(c, "INSERT INTO up_income(mid,date) VALUES(1,'2018-06-24') ON DUPLICATE KEY UPDATE date=VALUES(date)")
  16. m, last, err := d.UpIncomeStat(c, id, limit)
  17. ctx.Convey("Then err should be nil.m,last should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(last, convey.ShouldNotBeNil)
  20. ctx.So(m, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestIncomeInsertUpIncomeStat(t *testing.T) {
  26. convey.Convey("InsertUpIncomeStat", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. values = "(1,2,3,4,5)"
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. rows, err := d.InsertUpIncomeStat(c, values)
  33. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(rows, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestIncomeFixInsertUpIncomeStat(t *testing.T) {
  41. convey.Convey("FixInsertUpIncomeStat", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. values = "(1,2,3,4)"
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. rows, err := d.FixInsertUpIncomeStat(c, values)
  48. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(rows, convey.ShouldNotBeNil)
  51. })
  52. })
  53. })
  54. }