up_charge_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package charge
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestChargeGetUpCharges(t *testing.T) {
  8. convey.Convey("GetUpCharges", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. table = "up_daily_charge"
  12. date = "2018-06-24"
  13. offset = int64(0)
  14. limit = int64(100)
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. d.db.Exec(c, "INSERT INTO up_daily_charge(mid,date) VALUES(1, '2018-06-24')")
  18. last, charges, err := d.GetUpCharges(c, table, date, offset, limit)
  19. ctx.Convey("Then err should be nil.last,charges should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(charges, convey.ShouldNotBeNil)
  22. ctx.So(last, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestChargeInsertUpCharge(t *testing.T) {
  28. convey.Convey("InsertUpCharge", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. table = "up_daily_charge"
  32. values = "(1,2,3,'2018-06-24')"
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. rows, err := d.InsertUpCharge(c, table, values)
  36. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(rows, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }