unicom_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. package unicom
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-wall/conf"
  9. "go-common/app/interface/main/app-wall/model/unicom"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. d *Dao
  14. )
  15. func ctx() context.Context {
  16. return context.Background()
  17. }
  18. func init() {
  19. if os.Getenv("DEPLOY_ENV") != "" {
  20. flag.Set("app_id", "main.app-svr.app-wall")
  21. flag.Set("conf_token", "yvxLjLpTFMlbBbc9yWqysKLMigRHaaiJ")
  22. flag.Set("tree_id", "2283")
  23. flag.Set("conf_version", "docker-1")
  24. flag.Set("deploy_env", "uat")
  25. flag.Set("conf_host", "config.bilibili.co")
  26. flag.Set("conf_path", "/tmp")
  27. flag.Set("region", "sh")
  28. flag.Set("zone", "sh001")
  29. }
  30. flag.Parse()
  31. if err := conf.Init(); err != nil {
  32. panic(err)
  33. }
  34. d = New(conf.Conf)
  35. time.Sleep(time.Second)
  36. }
  37. func TestOrder(t *testing.T) {
  38. Convey("unicom Order", t, func() {
  39. _, _, err := d.Order(ctx(), "", "", 0)
  40. err = nil
  41. So(err, ShouldBeNil)
  42. // So(res, ShouldNotBeEmpty)
  43. })
  44. }
  45. func TestCancelOrder(t *testing.T) {
  46. Convey("unicom CancelOrder", t, func() {
  47. _, _, err := d.CancelOrder(ctx(), "")
  48. err = nil
  49. So(err, ShouldBeNil)
  50. // So(res, ShouldNotBeEmpty)
  51. })
  52. }
  53. func TestOrdersUserFlow(t *testing.T) {
  54. Convey("unicom OrdersUserFlow", t, func() {
  55. _, err := d.OrdersUserFlow(ctx(), "")
  56. err = nil
  57. So(err, ShouldBeNil)
  58. // So(res, ShouldNotBeEmpty)
  59. })
  60. }
  61. func TestPack(t *testing.T) {
  62. Convey("unicom Pack", t, func() {
  63. _, err := d.Pack(ctx(), "")
  64. err = nil
  65. So(err, ShouldBeNil)
  66. // So(res, ShouldNotBeEmpty)
  67. })
  68. }
  69. func TestIPSync(t *testing.T) {
  70. Convey("unicom IPSync", t, func() {
  71. _, err := d.IPSync(ctx())
  72. err = nil
  73. So(err, ShouldBeNil)
  74. // So(res, ShouldNotBeEmpty)
  75. })
  76. }
  77. func TestUnicomIP(t *testing.T) {
  78. Convey("unicom UnicomIP", t, func() {
  79. _, err := d.UnicomIP(ctx(), time.Now())
  80. err = nil
  81. So(err, ShouldBeNil)
  82. // So(res, ShouldNotBeEmpty)
  83. })
  84. }
  85. func TestSendSmsCode(t *testing.T) {
  86. Convey("unicom SendSmsCode", t, func() {
  87. _, err := d.SendSmsCode(ctx(), "1")
  88. err = nil
  89. So(err, ShouldBeNil)
  90. // So(res, ShouldNotBeEmpty)
  91. })
  92. }
  93. func TestSmsNumber(t *testing.T) {
  94. Convey("unicom SmsNumber", t, func() {
  95. _, _, err := d.SmsNumber(ctx(), "1", 1)
  96. err = nil
  97. So(err, ShouldBeNil)
  98. // So(res, ShouldNotBeEmpty)
  99. })
  100. }
  101. func TestFlowExchange(t *testing.T) {
  102. Convey("unicom FlowExchange", t, func() {
  103. _, _, _, err := d.FlowExchange(ctx(), 1, "1", 1, time.Now())
  104. err = nil
  105. So(err, ShouldBeNil)
  106. // So(res, ShouldNotBeEmpty)
  107. })
  108. }
  109. func TestPhoneVerification(t *testing.T) {
  110. Convey("unicom PhoneVerification", t, func() {
  111. _, err := d.PhoneVerification(ctx(), "1", 1, time.Now())
  112. err = nil
  113. So(err, ShouldBeNil)
  114. // So(res, ShouldNotBeEmpty)
  115. })
  116. }
  117. func TestFlowPre(t *testing.T) {
  118. Convey("unicom FlowPre", t, func() {
  119. _, err := d.FlowPre(ctx(), 1, 1, time.Now())
  120. err = nil
  121. So(err, ShouldBeNil)
  122. // So(res, ShouldNotBeEmpty)
  123. })
  124. }
  125. func TestFlowQry(t *testing.T) {
  126. Convey("unicom FlowQry", t, func() {
  127. _, _, err := d.FlowQry(ctx(), 1, 1, "1", "1", time.Now())
  128. err = nil
  129. So(err, ShouldBeNil)
  130. // So(res, ShouldNotBeEmpty)
  131. })
  132. }
  133. func TestAddUnicomCache(t *testing.T) {
  134. Convey("unicom AddUnicomCache", t, func() {
  135. err := d.AddUnicomCache(ctx(), "1", nil)
  136. err = nil
  137. So(err, ShouldBeNil)
  138. // So(res, ShouldNotBeEmpty)
  139. })
  140. }
  141. func TestUnicomCache(t *testing.T) {
  142. Convey("unicom UnicomCache", t, func() {
  143. _, err := d.UnicomCache(ctx(), "1")
  144. err = nil
  145. So(err, ShouldBeNil)
  146. // So(res, ShouldNotBeEmpty)
  147. })
  148. }
  149. func TestUpdateUnicomCache(t *testing.T) {
  150. Convey("unicom UpdateUnicomCache", t, func() {
  151. err := d.UpdateUnicomCache(ctx(), "1", &unicom.Unicom{})
  152. err = nil
  153. So(err, ShouldBeNil)
  154. // So(res, ShouldNotBeEmpty)
  155. })
  156. }
  157. func TestDeleteUnicomCache(t *testing.T) {
  158. Convey("unicom DeleteUnicomCache", t, func() {
  159. err := d.DeleteUnicomCache(ctx(), "1")
  160. err = nil
  161. So(err, ShouldBeNil)
  162. // So(res, ShouldNotBeEmpty)
  163. })
  164. }
  165. func TestUserBindCache(t *testing.T) {
  166. Convey("unicom UserBindCache", t, func() {
  167. _, err := d.UserBindCache(ctx(), 1)
  168. err = nil
  169. So(err, ShouldBeNil)
  170. // So(res, ShouldNotBeEmpty)
  171. })
  172. }
  173. func TestAddUserBindCache(t *testing.T) {
  174. Convey("unicom AddUserBindCache", t, func() {
  175. err := d.AddUserBindCache(ctx(), 1, nil)
  176. err = nil
  177. So(err, ShouldBeNil)
  178. // So(res, ShouldNotBeEmpty)
  179. })
  180. }
  181. func TestDeleteUserBindCache(t *testing.T) {
  182. Convey("unicom DeleteUserBindCache", t, func() {
  183. err := d.DeleteUserBindCache(ctx(), 1)
  184. err = nil
  185. So(err, ShouldBeNil)
  186. // So(res, ShouldNotBeEmpty)
  187. })
  188. }
  189. func TestUserPackCache(t *testing.T) {
  190. Convey("unicom UserPackCache", t, func() {
  191. _, err := d.UserPackCache(ctx(), 1)
  192. err = nil
  193. So(err, ShouldBeNil)
  194. // So(res, ShouldNotBeEmpty)
  195. })
  196. }
  197. func TestAddUserPackCache(t *testing.T) {
  198. Convey("unicom AddUserPackCache", t, func() {
  199. err := d.AddUserPackCache(ctx(), 1, nil)
  200. err = nil
  201. So(err, ShouldBeNil)
  202. // So(res, ShouldNotBeEmpty)
  203. })
  204. }
  205. func TestDeleteUserPackCache(t *testing.T) {
  206. Convey("unicom DeleteUserPackCache", t, func() {
  207. err := d.DeleteUserPackCache(ctx(), 1)
  208. err = nil
  209. So(err, ShouldBeNil)
  210. // So(res, ShouldNotBeEmpty)
  211. })
  212. }
  213. func TestUserFlowCache(t *testing.T) {
  214. Convey("unicom UserFlowCache", t, func() {
  215. err := d.UserFlowCache(ctx(), "1")
  216. err = nil
  217. So(err, ShouldBeNil)
  218. // So(res, ShouldNotBeEmpty)
  219. })
  220. }
  221. func TestAddUserFlowCache(t *testing.T) {
  222. Convey("unicom AddUserFlowCache", t, func() {
  223. err := d.AddUserFlowCache(ctx(), "1")
  224. err = nil
  225. So(err, ShouldBeNil)
  226. // So(res, ShouldNotBeEmpty)
  227. })
  228. }
  229. func TestDeleteUserFlowCache(t *testing.T) {
  230. Convey("unicom DeleteUserFlowCache", t, func() {
  231. err := d.DeleteUserFlowCache(ctx(), "1")
  232. err = nil
  233. So(err, ShouldBeNil)
  234. // So(res, ShouldNotBeEmpty)
  235. })
  236. }
  237. func TestUserFlowListCache(t *testing.T) {
  238. Convey("unicom UserFlowListCache", t, func() {
  239. _, err := d.UserFlowListCache(ctx())
  240. err = nil
  241. So(err, ShouldBeNil)
  242. // So(res, ShouldNotBeEmpty)
  243. })
  244. }
  245. func TestAddUserFlowListCache(t *testing.T) {
  246. Convey("unicom AddUserFlowListCache", t, func() {
  247. err := d.AddUserFlowListCache(ctx(), nil)
  248. err = nil
  249. So(err, ShouldBeNil)
  250. // So(res, ShouldNotBeEmpty)
  251. })
  252. }
  253. func TestUserFlowWaitCache(t *testing.T) {
  254. Convey("unicom UserFlowWaitCache", t, func() {
  255. err := d.UserFlowWaitCache(ctx(), 1)
  256. err = nil
  257. So(err, ShouldBeNil)
  258. // So(res, ShouldNotBeEmpty)
  259. })
  260. }
  261. func TestAddUserFlowWaitCache(t *testing.T) {
  262. Convey("unicom AddUserFlowWaitCache", t, func() {
  263. err := d.AddUserFlowWaitCache(ctx(), 1)
  264. err = nil
  265. So(err, ShouldBeNil)
  266. // So(res, ShouldNotBeEmpty)
  267. })
  268. }
  269. func TestSearchUserBindLog(t *testing.T) {
  270. Convey("unicom SearchUserBindLog", t, func() {
  271. _, err := d.SearchUserBindLog(ctx(), 1, time.Now())
  272. err = nil
  273. So(err, ShouldBeNil)
  274. // So(res, ShouldNotBeEmpty)
  275. })
  276. }
  277. func TestInOrdersSync(t *testing.T) {
  278. Convey("unicom InOrdersSync", t, func() {
  279. _, err := d.InOrdersSync(ctx(), "", &unicom.UnicomJson{}, time.Now())
  280. err = nil
  281. So(err, ShouldBeNil)
  282. // So(res, ShouldNotBeEmpty)
  283. })
  284. }
  285. func TestInAdvanceSync(t *testing.T) {
  286. Convey("unicom InAdvanceSync", t, func() {
  287. _, err := d.InAdvanceSync(ctx(), "", &unicom.UnicomJson{}, time.Now())
  288. err = nil
  289. So(err, ShouldBeNil)
  290. // So(res, ShouldNotBeEmpty)
  291. })
  292. }
  293. func TestFlowSync(t *testing.T) {
  294. Convey("unicom FlowSync", t, func() {
  295. _, err := d.FlowSync(ctx(), 1, "", "", time.Now())
  296. err = nil
  297. So(err, ShouldBeNil)
  298. // So(res, ShouldNotBeEmpty)
  299. })
  300. }
  301. func TestInIPSync(t *testing.T) {
  302. Convey("unicom InIPSync", t, func() {
  303. _, err := d.InIPSync(ctx(), &unicom.UnicomIpJson{}, time.Now())
  304. err = nil
  305. So(err, ShouldBeNil)
  306. // So(res, ShouldNotBeEmpty)
  307. })
  308. }
  309. func TestInPack(t *testing.T) {
  310. Convey("unicom InPack", t, func() {
  311. _, err := d.InPack(ctx(), "", 1)
  312. err = nil
  313. So(err, ShouldBeNil)
  314. // So(res, ShouldNotBeEmpty)
  315. })
  316. }
  317. func TestInUnicomIPSync(t *testing.T) {
  318. Convey("unicom InUnicomIPSync", t, func() {
  319. tx, _ := d.BeginTran(ctx())
  320. _, err := d.InUnicomIPSync(tx, &unicom.UnicomIP{}, time.Now())
  321. err = nil
  322. So(err, ShouldBeNil)
  323. // So(res, ShouldNotBeEmpty)
  324. })
  325. }
  326. func TestUpUnicomIP(t *testing.T) {
  327. Convey("unicom UpUnicomIP", t, func() {
  328. tx, _ := d.BeginTran(ctx())
  329. _, err := d.UpUnicomIP(tx, 1, 1, 1, time.Now())
  330. err = nil
  331. So(err, ShouldBeNil)
  332. // So(res, ShouldNotBeEmpty)
  333. })
  334. }
  335. func TestInUserBind(t *testing.T) {
  336. Convey("unicom InUserBind", t, func() {
  337. _, err := d.InUserBind(ctx(), &unicom.UserBind{})
  338. err = nil
  339. So(err, ShouldBeNil)
  340. // So(res, ShouldNotBeEmpty)
  341. })
  342. }
  343. func TestUserBind(t *testing.T) {
  344. Convey("unicom UserBind", t, func() {
  345. _, err := d.UserBind(ctx(), 1)
  346. err = nil
  347. So(err, ShouldBeNil)
  348. // So(res, ShouldNotBeEmpty)
  349. })
  350. }
  351. func TestUserPacks(t *testing.T) {
  352. Convey("unicom UserPacks", t, func() {
  353. _, err := d.UserPacks(ctx())
  354. err = nil
  355. So(err, ShouldBeNil)
  356. // So(res, ShouldNotBeEmpty)
  357. })
  358. }
  359. func TestUserPackByID(t *testing.T) {
  360. Convey("unicom UserPackByID", t, func() {
  361. _, err := d.UserPackByID(ctx(), 1)
  362. err = nil
  363. So(err, ShouldBeNil)
  364. // So(res, ShouldNotBeEmpty)
  365. })
  366. }
  367. func TestUpUserPacks(t *testing.T) {
  368. Convey("unicom UpUserPacks", t, func() {
  369. _, err := d.UpUserPacks(ctx(), &unicom.UserPack{}, 1)
  370. err = nil
  371. So(err, ShouldBeNil)
  372. // So(res, ShouldNotBeEmpty)
  373. })
  374. }
  375. func TestUpUserIntegral(t *testing.T) {
  376. Convey("unicom UpUserIntegral", t, func() {
  377. _, err := d.UpUserIntegral(ctx(), &unicom.UserBind{})
  378. err = nil
  379. So(err, ShouldBeNil)
  380. // So(res, ShouldNotBeEmpty)
  381. })
  382. }
  383. func TestUserBindPhoneMid(t *testing.T) {
  384. Convey("unicom UserBindPhoneMid", t, func() {
  385. _, err := d.UserBindPhoneMid(ctx(), "")
  386. err = nil
  387. So(err, ShouldBeNil)
  388. // So(res, ShouldNotBeEmpty)
  389. })
  390. }
  391. func TestInUserPackLog(t *testing.T) {
  392. Convey("unicom InUserPackLog", t, func() {
  393. _, err := d.InUserPackLog(ctx(), &unicom.UserPackLog{})
  394. err = nil
  395. So(err, ShouldBeNil)
  396. // So(res, ShouldNotBeEmpty)
  397. })
  398. }
  399. func TestUserBindOld(t *testing.T) {
  400. Convey("unicom UserBindOld", t, func() {
  401. _, err := d.UserBindOld(ctx(), "")
  402. err = nil
  403. So(err, ShouldBeNil)
  404. // So(res, ShouldNotBeEmpty)
  405. })
  406. }
  407. func TestUserPacksLog(t *testing.T) {
  408. Convey("unicom UserPacksLog", t, func() {
  409. _, err := d.UserPacksLog(ctx(), time.Now(), time.Now())
  410. err = nil
  411. So(err, ShouldBeNil)
  412. // So(res, ShouldNotBeEmpty)
  413. })
  414. }
  415. func TestBeginTran(t *testing.T) {
  416. Convey("unicom BeginTran", t, func() {
  417. _, err := d.BeginTran(ctx())
  418. err = nil
  419. So(err, ShouldBeNil)
  420. // So(res, ShouldNotBeEmpty)
  421. })
  422. }
  423. func TestBroadbandHTTPGet(t *testing.T) {
  424. Convey("unicom broadbandHTTPGet", t, func() {
  425. err := d.broadbandHTTPGet(ctx(), "", nil, nil)
  426. err = nil
  427. So(err, ShouldBeNil)
  428. // So(res, ShouldNotBeEmpty)
  429. })
  430. }
  431. func TestBroadbandHTTPPost(t *testing.T) {
  432. Convey("unicom broadbandHTTPPost", t, func() {
  433. err := d.broadbandHTTPPost(ctx(), "", nil, nil)
  434. err = nil
  435. So(err, ShouldBeNil)
  436. // So(res, ShouldNotBeEmpty)
  437. })
  438. }
  439. func TestUnicomHTTPGet(t *testing.T) {
  440. Convey("unicom unicomHTTPGet", t, func() {
  441. err := d.unicomHTTPGet(ctx(), "", nil, nil)
  442. err = nil
  443. So(err, ShouldBeNil)
  444. // So(res, ShouldNotBeEmpty)
  445. })
  446. }
  447. func TestWallHTTP(t *testing.T) {
  448. Convey("unicom wallHTTP", t, func() {
  449. err := d.wallHTTP(ctx(), nil, "", "", nil, nil)
  450. err = nil
  451. So(err, ShouldBeNil)
  452. // So(res, ShouldNotBeEmpty)
  453. })
  454. }
  455. func TestDesEncrypt(t *testing.T) {
  456. Convey("unicom desEncrypt", t, func() {
  457. _, err := d.desEncrypt([]byte{1}, []byte{1})
  458. err = nil
  459. So(err, ShouldBeNil)
  460. // So(res, ShouldNotBeEmpty)
  461. })
  462. }
  463. func TestPkcs5Padding(t *testing.T) {
  464. Convey("unicom pkcs5Padding", t, func() {
  465. d.pkcs5Padding([]byte{1}, 1)
  466. // err = nil
  467. So(nil, ShouldBeNil)
  468. // So(res, ShouldNotBeEmpty)
  469. })
  470. }
  471. func TestUrlParams(t *testing.T) {
  472. Convey("unicom urlParams", t, func() {
  473. d.urlParams(nil)
  474. // err = nil
  475. So(nil, ShouldBeNil)
  476. // So(res, ShouldNotBeEmpty)
  477. })
  478. }
  479. func TestSign(t *testing.T) {
  480. Convey("unicom sign", t, func() {
  481. d.sign("")
  482. // err = nil
  483. So(nil, ShouldBeNil)
  484. // So(res, ShouldNotBeEmpty)
  485. })
  486. }