memcache_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/dm2/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyXML(t *testing.T) {
  9. convey.Convey("keyXML", t, func(ctx convey.C) {
  10. var (
  11. oid = int64(0)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := keyXML(oid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaokeySubject(t *testing.T) {
  22. convey.Convey("keySubject", t, func(ctx convey.C) {
  23. var (
  24. tp = int32(0)
  25. oid = int64(0)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. p1 := keySubject(tp, oid)
  29. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  30. ctx.So(p1, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaokeyAjax(t *testing.T) {
  36. convey.Convey("keyAjax", t, func(ctx convey.C) {
  37. var (
  38. oid = int64(0)
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. p1 := keyAjax(oid)
  42. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  43. ctx.So(p1, convey.ShouldNotBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestDaokeyTransferLock(t *testing.T) {
  49. convey.Convey("keyTransferLock", t, func(ctx convey.C) {
  50. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  51. p1 := keyTransferLock()
  52. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  53. ctx.So(p1, convey.ShouldNotBeNil)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoDelXMLCache(t *testing.T) {
  59. convey.Convey("DelXMLCache", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. oid = int64(0)
  63. )
  64. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  65. testDao.DelXMLCache(c, oid)
  66. })
  67. })
  68. }
  69. func TestDaoAddXMLCache(t *testing.T) {
  70. convey.Convey("AddXMLCache", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. oid = int64(0)
  74. value = []byte("")
  75. )
  76. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  77. err := testDao.AddXMLCache(c, oid, value)
  78. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoXMLCache(t *testing.T) {
  85. convey.Convey("XMLCache", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. oid = int64(0)
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. testDao.XMLCache(c, oid)
  92. })
  93. })
  94. }
  95. func TestDaoSubjectCache(t *testing.T) {
  96. convey.Convey("SubjectCache", t, func(ctx convey.C) {
  97. var (
  98. c = context.Background()
  99. tp = int32(0)
  100. oid = int64(0)
  101. )
  102. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  103. testDao.SubjectCache(c, tp, oid)
  104. })
  105. })
  106. }
  107. func TestDaoSubjectsCache(t *testing.T) {
  108. convey.Convey("SubjectsCache", t, func(ctx convey.C) {
  109. var (
  110. c = context.Background()
  111. tp = int32(0)
  112. oids = []int64{}
  113. )
  114. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  115. testDao.SubjectsCache(c, tp, oids)
  116. })
  117. })
  118. }
  119. func TestDaoAddSubjectCache(t *testing.T) {
  120. convey.Convey("AddSubjectCache", t, func(ctx convey.C) {
  121. var (
  122. c = context.Background()
  123. sub = &model.Subject{}
  124. )
  125. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  126. err := testDao.AddSubjectCache(c, sub)
  127. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  128. ctx.So(err, convey.ShouldBeNil)
  129. })
  130. })
  131. })
  132. }
  133. func TestDaoDelSubjectCache(t *testing.T) {
  134. convey.Convey("DelSubjectCache", t, func(ctx convey.C) {
  135. var (
  136. c = context.Background()
  137. tp = int32(0)
  138. oid = int64(0)
  139. )
  140. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  141. testDao.DelSubjectCache(c, tp, oid)
  142. })
  143. })
  144. }
  145. func TestDaoAddTransferLock(t *testing.T) {
  146. convey.Convey("AddTransferLock", t, func(ctx convey.C) {
  147. var (
  148. c = context.Background()
  149. )
  150. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  151. succeed := testDao.AddTransferLock(c)
  152. ctx.Convey("Then succeed should not be nil.", func(ctx convey.C) {
  153. ctx.So(succeed, convey.ShouldNotBeNil)
  154. })
  155. })
  156. })
  157. }
  158. func TestDaoDelTransferLock(t *testing.T) {
  159. convey.Convey("DelTransferLock", t, func(ctx convey.C) {
  160. var (
  161. c = context.Background()
  162. )
  163. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  164. testDao.DelTransferLock(c)
  165. })
  166. })
  167. }
  168. func TestDaoDelAjaxDMCache(t *testing.T) {
  169. convey.Convey("DelAjaxDMCache", t, func(ctx convey.C) {
  170. var (
  171. c = context.Background()
  172. oid = int64(0)
  173. )
  174. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  175. testDao.DelAjaxDMCache(c, oid)
  176. })
  177. })
  178. }