mysql_test.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/interface/main/answer/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestHit(t *testing.T) {
  10. convey.Convey("hit", t, func() {
  11. p1 := hit(0)
  12. convey.So(p1, convey.ShouldNotBeNil)
  13. })
  14. }
  15. func TestDaoPendantHistory(t *testing.T) {
  16. convey.Convey("PendantHistory", t, func() {
  17. hid, status, err := d.PendantHistory(context.Background(), 0)
  18. convey.So(err, convey.ShouldBeNil)
  19. convey.So(status, convey.ShouldNotBeNil)
  20. convey.So(hid, convey.ShouldNotBeNil)
  21. })
  22. }
  23. func TestDaoHistory(t *testing.T) {
  24. convey.Convey("History", t, func() {
  25. res, err := d.History(context.Background(), 0)
  26. convey.So(err, convey.ShouldBeNil)
  27. convey.So(res, convey.ShouldNotBeNil)
  28. })
  29. }
  30. func TestDaoHistoryByHid(t *testing.T) {
  31. convey.Convey("HistoryByHid", t, func() {
  32. res, err := d.HistoryByHid(context.Background(), 0)
  33. convey.So(err, convey.ShouldBeNil)
  34. convey.So(res, convey.ShouldNotBeNil)
  35. })
  36. }
  37. func TestDaoOldHistory(t *testing.T) {
  38. convey.Convey("OldHistory", t, func() {
  39. res, err := d.OldHistory(context.Background(), 0, 0)
  40. convey.So(err, convey.ShouldBeNil)
  41. convey.So(res, convey.ShouldNotBeNil)
  42. })
  43. }
  44. func TestDaoSharingIndexByHid(t *testing.T) {
  45. convey.Convey("SharingIndexByHid", t, func() {
  46. res, err := d.SharingIndexByHid(context.Background(), 0)
  47. convey.So(err, convey.ShouldBeNil)
  48. convey.So(res, convey.ShouldNotBeNil)
  49. })
  50. }
  51. func TestDaoAddPendantHistory(t *testing.T) {
  52. convey.Convey("AddPendantHistory", t, func() {
  53. affected, err := d.AddPendantHistory(context.Background(), time.Now().Unix(), time.Now().Unix())
  54. convey.So(err, convey.ShouldBeNil)
  55. convey.So(affected, convey.ShouldNotBeNil)
  56. })
  57. }
  58. func TestDaoHistorySuit(t *testing.T) {
  59. var (
  60. err error
  61. affected int64
  62. hid = time.Now().Unix()
  63. )
  64. ans := &model.AnswerHistory{
  65. Hid: hid,
  66. }
  67. convey.Convey("AddHistory", t, func() {
  68. affected, _, err = d.AddHistory(context.Background(), 0, ans)
  69. convey.So(err, convey.ShouldBeNil)
  70. convey.So(affected, convey.ShouldNotBeNil)
  71. })
  72. convey.Convey("HistoryByHid", t, func() {
  73. ans, err = d.HistoryByHid(context.Background(), hid)
  74. convey.So(err, convey.ShouldBeNil)
  75. convey.So(affected, convey.ShouldNotBeNil)
  76. })
  77. convey.Convey("SetHistory", t, func() {
  78. affected, err = d.SetHistory(context.Background(), 0, ans)
  79. convey.So(err, convey.ShouldBeNil)
  80. convey.So(affected, convey.ShouldNotBeNil)
  81. })
  82. }
  83. func TestDaoUpdateLevel(t *testing.T) {
  84. convey.Convey("UpdateLevel", t, func() {
  85. ret, err := d.UpdateLevel(context.Background(), 0, 0, 0, 0)
  86. convey.So(err, convey.ShouldBeNil)
  87. convey.So(ret, convey.ShouldNotBeNil)
  88. })
  89. }
  90. func TestDaoUpdateCaptcha(t *testing.T) {
  91. convey.Convey("UpdateCaptcha", t, func() {
  92. ret, err := d.UpdateCaptcha(context.Background(), 0, 0, 0)
  93. convey.So(err, convey.ShouldBeNil)
  94. convey.So(ret, convey.ShouldNotBeNil)
  95. })
  96. }
  97. func TestDaoUpdateStepTwoTime(t *testing.T) {
  98. convey.Convey("UpdateStepTwoTime", t, func() {
  99. ret, err := d.UpdateStepTwoTime(context.Background(), 0, 0, time.Now())
  100. convey.So(err, convey.ShouldBeNil)
  101. convey.So(ret, convey.ShouldNotBeNil)
  102. })
  103. }
  104. func TestDaoUpdateExtraStartTime(t *testing.T) {
  105. convey.Convey("UpdateExtraStartTime", t, func() {
  106. ret, err := d.UpdateExtraStartTime(context.Background(), 0, 0, time.Now())
  107. convey.So(err, convey.ShouldBeNil)
  108. convey.So(ret, convey.ShouldNotBeNil)
  109. })
  110. }
  111. func TestDaoUpdateExtraRet(t *testing.T) {
  112. convey.Convey("UpdateExtraRet", t, func() {
  113. ret, err := d.UpdateExtraRet(context.Background(), 0, 0, 0, 0)
  114. convey.So(err, convey.ShouldBeNil)
  115. convey.So(ret, convey.ShouldNotBeNil)
  116. })
  117. }
  118. func TestDaoUpPendantHistory(t *testing.T) {
  119. convey.Convey("UpPendantHistory", t, func() {
  120. ret, err := d.UpPendantHistory(context.Background(), 0, 0)
  121. convey.So(err, convey.ShouldBeNil)
  122. convey.So(ret, convey.ShouldNotBeNil)
  123. })
  124. }
  125. func TestDaoQidsExtraByState(t *testing.T) {
  126. convey.Convey("QidsExtraByState", t, func() {
  127. _, err := d.QidsExtraByState(context.Background(), 1)
  128. convey.So(err, convey.ShouldBeNil)
  129. })
  130. }
  131. func TestDaoExtraByIds(t *testing.T) {
  132. convey.Convey("ExtraByIds", t, func() {
  133. res, err := d.ExtraByIds(context.Background(), []int64{1, 2, 3})
  134. convey.So(err, convey.ShouldBeNil)
  135. convey.So(res, convey.ShouldNotBeNil)
  136. })
  137. }
  138. func TestDaoTypes(t *testing.T) {
  139. convey.Convey("Types", t, func() {
  140. _, err := d.Types(context.Background())
  141. convey.So(err, convey.ShouldBeNil)
  142. })
  143. }
  144. func TestDaoByIds(t *testing.T) {
  145. convey.Convey("ByIds", t, func() {
  146. _, err := d.ByIds(context.Background(), []int64{1, 2, 3})
  147. convey.So(err, convey.ShouldBeNil)
  148. })
  149. }
  150. func TestDaoQidsByState(t *testing.T) {
  151. convey.Convey("QidsByState", t, func() {
  152. _, err := d.QidsByState(context.Background(), 1)
  153. convey.So(err, convey.ShouldBeNil)
  154. })
  155. }