up_base_info_test.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package upcrmdao
  2. import (
  3. "testing"
  4. "github.com/smartystreets/goconvey/convey"
  5. "time"
  6. )
  7. func TestUpcrmdaoAsPrScore(t *testing.T) {
  8. convey.Convey("AsPrScore", t, func(ctx convey.C) {
  9. var info *UpQualityInfo
  10. history := info.AsPrScore()
  11. ctx.Convey("Then history should not be nil.", func(ctx convey.C) {
  12. ctx.So(history, convey.ShouldNotBeNil)
  13. })
  14. })
  15. }
  16. func TestUpcrmdaoAsQualityScore(t *testing.T) {
  17. convey.Convey("AsQualityScore", t, func(ctx convey.C) {
  18. var info *UpQualityInfo
  19. history := info.AsQualityScore()
  20. ctx.Convey("Then history should not be nil.", func(ctx convey.C) {
  21. ctx.So(history, convey.ShouldNotBeNil)
  22. })
  23. })
  24. }
  25. func TestUpcrmdaoUpdateCreditScore(t *testing.T) {
  26. var (
  27. score = int(0)
  28. mid = int64(0)
  29. )
  30. convey.Convey("UpdateCreditScore", t, func(ctx convey.C) {
  31. affectRow, err := d.UpdateCreditScore(score, mid)
  32. err = IgnoreErr(err)
  33. ctx.Convey("Then err should be nil.affectRow should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(affectRow, convey.ShouldNotBeNil)
  36. })
  37. })
  38. }
  39. func TestUpcrmdaoUpdateQualityAndPrScore(t *testing.T) {
  40. var (
  41. prScore = int(0)
  42. qualityScore = int(0)
  43. mid = int64(0)
  44. )
  45. convey.Convey("UpdateQualityAndPrScore", t, func(ctx convey.C) {
  46. affectRow, err := d.UpdateQualityAndPrScore(prScore, qualityScore, mid)
  47. err = IgnoreErr(err)
  48. ctx.Convey("Then err should be nil.affectRow should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(affectRow, convey.ShouldNotBeNil)
  51. })
  52. })
  53. }
  54. func TestUpcrmdaoInsertScoreHistory(t *testing.T) {
  55. var (
  56. info = &UpQualityInfo{}
  57. )
  58. convey.Convey("InsertScoreHistory", t, func(ctx convey.C) {
  59. affectRow, err := d.InsertScoreHistory(info)
  60. err = IgnoreErr(err)
  61. ctx.Convey("Then err should be nil.affectRow should not be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. ctx.So(affectRow, convey.ShouldNotBeNil)
  64. })
  65. })
  66. }
  67. func TestUpcrmdaoInsertBatchScoreHistory(t *testing.T) {
  68. var (
  69. infoList = []*UpQualityInfo{{Mid: 100, Cdate: time.Now().Format(TimeFmtDate)}}
  70. tablenum = int(0)
  71. )
  72. convey.Convey("InsertBatchScoreHistory", t, func(ctx convey.C) {
  73. affectRow, err := d.InsertBatchScoreHistory(infoList, tablenum)
  74. err = IgnoreErr(err)
  75. ctx.Convey("Then err should be nil.affectRow should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. ctx.So(affectRow, convey.ShouldNotBeNil)
  78. })
  79. })
  80. }