mysql_test.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/dm/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestUpSubjectAttr(t *testing.T) {
  9. Convey("test update subject attr", t, func() {
  10. _, err := testDao.UpSubjectAttr(context.TODO(), 1, 1221, 16)
  11. So(err, ShouldBeNil)
  12. })
  13. }
  14. func TestUpSubjectCount(t *testing.T) {
  15. Convey("update count in subject", t, func() {
  16. _, err := testDao.UpSubjectCount(context.TODO(), 1, 1221, 1, 1)
  17. So(err, ShouldBeNil)
  18. })
  19. }
  20. func TestIncrSubjectCount(t *testing.T) {
  21. Convey("update count in subject", t, func() {
  22. _, err := testDao.IncrSubjectCount(context.TODO(), 1, 1221, 1)
  23. So(err, ShouldBeNil)
  24. })
  25. }
  26. func TestIncrSubMoveCount(t *testing.T) {
  27. Convey("update move count in subject", t, func() {
  28. _, err := testDao.IncrSubMoveCount(context.TODO(), 1, 1221, 1)
  29. So(err, ShouldBeNil)
  30. })
  31. }
  32. func TestIncrSubCount(t *testing.T) {
  33. Convey("update count in subject", t, func() {
  34. _, err := testDao.IncrSubjectCount(context.TODO(), 1, 1221, 1)
  35. So(err, ShouldBeNil)
  36. })
  37. }
  38. func TestUpSubjectPool(t *testing.T) {
  39. Convey("update childpool in subject", t, func() {
  40. _, err := testDao.UpSubjectPool(context.TODO(), 1, 1221, 1)
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. func TestUpSubjectState(t *testing.T) {
  45. Convey("update state in subject", t, func() {
  46. _, err := testDao.UpSubjectState(context.TODO(), 1, 1221, 1)
  47. So(err, ShouldBeNil)
  48. })
  49. }
  50. func TestUpSubjectMaxlimit(t *testing.T) {
  51. Convey("update maxlimit in subject", t, func() {
  52. _, err := testDao.UpSubjectMaxlimit(context.TODO(), 1, 1221, 8000)
  53. So(err, ShouldBeNil)
  54. })
  55. }
  56. func TestSubject(t *testing.T) {
  57. var (
  58. tp int32 = 1
  59. oid int64 = 1508
  60. c = context.TODO()
  61. )
  62. Convey("subject test", t, func() {
  63. _, err := testDao.Subject(c, tp, oid)
  64. So(err, ShouldBeNil)
  65. })
  66. }
  67. func TestSubjects(t *testing.T) {
  68. oids := []int64{1221, 1321}
  69. Convey("subject test", t, func() {
  70. res, err := testDao.Subjects(context.TODO(), 1, oids)
  71. So(err, ShouldBeNil)
  72. So(res, ShouldNotBeEmpty)
  73. })
  74. }
  75. func TestChangeReportStat(t *testing.T) {
  76. var (
  77. c = context.TODO()
  78. cid int64 = 1
  79. dmids = []int64{1, 2, 3, 4, 5}
  80. state = model.StatFirstDelete
  81. )
  82. Convey("update dm report state and err shoule be nil", t, func() {
  83. err := testDao.ChangeReportStat(c, cid, dmids, state)
  84. So(err, ShouldBeNil)
  85. })
  86. }
  87. func TestIgnoreReport(t *testing.T) {
  88. var (
  89. cid int64 = 1
  90. c = context.TODO()
  91. dmids = []int64{1, 2, 3, 4, 5}
  92. state int8 = 4
  93. )
  94. Convey("ignore dm report state and err shoule be nil", t, func() {
  95. err := testDao.IgnoreReport(c, cid, dmids, state)
  96. So(err, ShouldBeNil)
  97. })
  98. }
  99. func TestReports(t *testing.T) {
  100. var (
  101. cid int64 = 10109027
  102. c = context.TODO()
  103. dmids = []int64{719218595}
  104. )
  105. Convey("", t, func() {
  106. res, err := testDao.Reports(c, cid, dmids)
  107. So(err, ShouldBeNil)
  108. So(res, ShouldNotBeEmpty)
  109. for _, r := range res {
  110. t.Logf("===:%+v", r)
  111. }
  112. })
  113. }
  114. func TestReportUsers(t *testing.T) {
  115. var (
  116. tableID int64 = 1
  117. c = context.TODO()
  118. state = model.NoticeUnsend
  119. dmids = []int64{1, 2, 3, 4, 5}
  120. )
  121. Convey("", t, func() {
  122. _, err := testDao.ReportUsers(c, tableID, dmids, state)
  123. So(err, ShouldBeNil)
  124. })
  125. }
  126. func TestUpReportUserState(t *testing.T) {
  127. var (
  128. tableID int64 = 1
  129. c = context.TODO()
  130. state = model.NoticeSend
  131. dmids = []int64{1, 2, 3, 4, 5}
  132. )
  133. Convey("", t, func() {
  134. _, err := testDao.UpReportUserState(c, tableID, dmids, state)
  135. So(err, ShouldBeNil)
  136. })
  137. }
  138. func TestAddReportLog(t *testing.T) {
  139. var (
  140. tableID int64 = 1
  141. c = context.TODO()
  142. lg = &model.ReportLog{
  143. ID: 1,
  144. Did: 1234,
  145. AdminID: 1,
  146. }
  147. )
  148. Convey("", t, func() {
  149. err := testDao.AddReportLog(c, tableID, []*model.ReportLog{lg})
  150. So(err, ShouldBeNil)
  151. })
  152. }
  153. func TestReportLog(t *testing.T) {
  154. var (
  155. dmid int64 = 719918888
  156. c = context.TODO()
  157. )
  158. Convey("", t, func() {
  159. res, err := testDao.ReportLog(c, dmid)
  160. So(err, ShouldBeNil)
  161. So(res, ShouldNotBeEmpty)
  162. })
  163. }