dao_test.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. package black
  2. import (
  3. "context"
  4. "reflect"
  5. "testing"
  6. "go-common/app/interface/main/app-feed/conf"
  7. "go-common/library/cache/redis"
  8. httpx "go-common/library/net/http/blademaster"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestNew(t *testing.T) {
  12. type args struct {
  13. c *conf.Config
  14. }
  15. tests := []struct {
  16. name string
  17. args args
  18. wantD *Dao
  19. }{
  20. // TODO: Add test cases.
  21. }
  22. for _, tt := range tests {
  23. t.Run(tt.name, func(t *testing.T) {
  24. if gotD := New(tt.args.c); !reflect.DeepEqual(gotD, tt.wantD) {
  25. t.Errorf("New() = %v, want %v", gotD, tt.wantD)
  26. }
  27. })
  28. Convey(tt.name, func(t *testing.T) {
  29. gotD := New(tt.args.c)
  30. So(gotD, ShouldEqual, tt.wantD)
  31. })
  32. }
  33. }
  34. func TestDao_Ping(t *testing.T) {
  35. type fields struct {
  36. clientAsyn *httpx.Client
  37. redis *redis.Pool
  38. expireRds int32
  39. aCh chan func()
  40. }
  41. type args struct {
  42. c context.Context
  43. }
  44. tests := []struct {
  45. name string
  46. fields fields
  47. args args
  48. wantErr bool
  49. }{
  50. // TODO: Add test cases.
  51. }
  52. for _, tt := range tests {
  53. t.Run(tt.name, func(t *testing.T) {
  54. d := &Dao{
  55. clientAsyn: tt.fields.clientAsyn,
  56. redis: tt.fields.redis,
  57. expireRds: tt.fields.expireRds,
  58. aCh: tt.fields.aCh,
  59. }
  60. if err := d.Ping(tt.args.c); (err != nil) != tt.wantErr {
  61. t.Errorf("Dao.Ping() error = %v, wantErr %v", err, tt.wantErr)
  62. }
  63. })
  64. }
  65. }
  66. func TestDao_AddBlacklist(t *testing.T) {
  67. type fields struct {
  68. clientAsyn *httpx.Client
  69. redis *redis.Pool
  70. expireRds int32
  71. aCh chan func()
  72. }
  73. type args struct {
  74. mid int64
  75. aid int64
  76. }
  77. tests := []struct {
  78. name string
  79. fields fields
  80. args args
  81. }{
  82. // TODO: Add test cases.
  83. }
  84. for _, tt := range tests {
  85. t.Run(tt.name, func(t *testing.T) {
  86. d := &Dao{
  87. clientAsyn: tt.fields.clientAsyn,
  88. redis: tt.fields.redis,
  89. expireRds: tt.fields.expireRds,
  90. aCh: tt.fields.aCh,
  91. }
  92. d.AddBlacklist(tt.args.mid, tt.args.aid)
  93. })
  94. }
  95. }
  96. func TestDao_DelBlacklist(t *testing.T) {
  97. type fields struct {
  98. clientAsyn *httpx.Client
  99. redis *redis.Pool
  100. expireRds int32
  101. aCh chan func()
  102. }
  103. type args struct {
  104. mid int64
  105. aid int64
  106. }
  107. tests := []struct {
  108. name string
  109. fields fields
  110. args args
  111. }{
  112. // TODO: Add test cases.
  113. }
  114. for _, tt := range tests {
  115. t.Run(tt.name, func(t *testing.T) {
  116. d := &Dao{
  117. clientAsyn: tt.fields.clientAsyn,
  118. redis: tt.fields.redis,
  119. expireRds: tt.fields.expireRds,
  120. aCh: tt.fields.aCh,
  121. }
  122. d.DelBlacklist(tt.args.mid, tt.args.aid)
  123. })
  124. }
  125. }
  126. func TestDao_BlackList(t *testing.T) {
  127. type fields struct {
  128. clientAsyn *httpx.Client
  129. redis *redis.Pool
  130. expireRds int32
  131. aCh chan func()
  132. }
  133. type args struct {
  134. c context.Context
  135. mid int64
  136. }
  137. tests := []struct {
  138. name string
  139. fields fields
  140. args args
  141. wantAidm map[int64]struct{}
  142. wantErr bool
  143. }{
  144. // TODO: Add test cases.
  145. }
  146. for _, tt := range tests {
  147. t.Run(tt.name, func(t *testing.T) {
  148. d := &Dao{
  149. clientAsyn: tt.fields.clientAsyn,
  150. redis: tt.fields.redis,
  151. expireRds: tt.fields.expireRds,
  152. aCh: tt.fields.aCh,
  153. }
  154. gotAidm, err := d.BlackList(tt.args.c, tt.args.mid)
  155. if (err != nil) != tt.wantErr {
  156. t.Errorf("Dao.BlackList() error = %v, wantErr %v", err, tt.wantErr)
  157. return
  158. }
  159. if !reflect.DeepEqual(gotAidm, tt.wantAidm) {
  160. t.Errorf("Dao.BlackList() = %v, want %v", gotAidm, tt.wantAidm)
  161. }
  162. })
  163. }
  164. }
  165. func TestDao_addCache(t *testing.T) {
  166. type fields struct {
  167. clientAsyn *httpx.Client
  168. redis *redis.Pool
  169. expireRds int32
  170. aCh chan func()
  171. }
  172. type args struct {
  173. i func()
  174. }
  175. tests := []struct {
  176. name string
  177. fields fields
  178. args args
  179. }{
  180. // TODO: Add test cases.
  181. }
  182. for _, tt := range tests {
  183. t.Run(tt.name, func(t *testing.T) {
  184. d := &Dao{
  185. clientAsyn: tt.fields.clientAsyn,
  186. redis: tt.fields.redis,
  187. expireRds: tt.fields.expireRds,
  188. aCh: tt.fields.aCh,
  189. }
  190. d.addCache(tt.args.i)
  191. })
  192. }
  193. }
  194. func TestDao_cacheproc(t *testing.T) {
  195. type fields struct {
  196. clientAsyn *httpx.Client
  197. redis *redis.Pool
  198. expireRds int32
  199. aCh chan func()
  200. }
  201. tests := []struct {
  202. name string
  203. fields fields
  204. }{
  205. // TODO: Add test cases.
  206. }
  207. for _, tt := range tests {
  208. t.Run(tt.name, func(t *testing.T) {
  209. d := &Dao{
  210. clientAsyn: tt.fields.clientAsyn,
  211. redis: tt.fields.redis,
  212. expireRds: tt.fields.expireRds,
  213. aCh: tt.fields.aCh,
  214. }
  215. d.cacheproc()
  216. })
  217. }
  218. }