charge_ratio_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAvDailyIncCharge(t *testing.T) {
  8. convey.Convey("AvDailyIncCharge", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. avID = int64(10)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. Exec(c, "INSERT INTO av_daily_charge_06(av_id,inc_charge,date,upload_time) VALUES(10, 100, '2018-06-24', '2018-06-24') ON DUPLICATE KEY UPDATE av_id=VALUES(av_id)")
  15. incCharge, tagID, err := d.AvDailyIncCharge(c, avID)
  16. ctx.Convey("Then err should be nil.incCharge,tagID should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(tagID, convey.ShouldNotBeNil)
  19. ctx.So(incCharge, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoAvChargeRatio(t *testing.T) {
  25. convey.Convey("AvChargeRatio", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. id = int64(10)
  29. limit = int64(1000)
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. m, last, err := d.AvChargeRatio(c, id, limit)
  33. ctx.Convey("Then err should be nil.m,last should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(last, convey.ShouldNotBeNil)
  36. ctx.So(m, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }