bplus_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "gopkg.in/h2non/gock.v1"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDao_GroupsCount(t *testing.T) {
  9. convey.Convey("test group count", t, func(ctx convey.C) {
  10. defer gock.OffAll()
  11. httpMock("GET", d.groupsCountURL).Reply(200).JSON(`{"code":0,"data":{"num":1}}`)
  12. mid := int64(28272030)
  13. vmid := int64(28272030)
  14. data, err := d.GroupsCount(context.Background(), mid, vmid)
  15. convey.So(err, convey.ShouldBeNil)
  16. convey.So(data, convey.ShouldNotBeNil)
  17. convey.Printf("%d", data)
  18. })
  19. }
  20. func TestDao_DynamicCnt(t *testing.T) {
  21. convey.Convey("test dynamic cnt", t, func(ctx convey.C) {
  22. defer gock.OffAll()
  23. httpMock("GET", d.dynamicCntURL).Reply(200).JSON(`{"code":0,"msg":"","message":"","data":{"items":[{"uid":2089809,"num":345}],"_gt_":0}}`)
  24. vmid := int64(2089809)
  25. data, err := d.DynamicCnt(context.Background(), vmid)
  26. convey.So(err, convey.ShouldBeNil)
  27. convey.Printf("%d", data)
  28. })
  29. }
  30. func TestDao_DynamicList(t *testing.T) {
  31. convey.Convey("test dynamic list", t, func(ctx convey.C) {
  32. mid := int64(29313802)
  33. vmid := int64(34709144)
  34. data, err := d.DynamicList(context.Background(), mid, vmid, 0, 16, 1)
  35. convey.So(err, convey.ShouldBeNil)
  36. convey.Printf("%d", data)
  37. })
  38. }
  39. func TestDao_Dynamic(t *testing.T) {
  40. convey.Convey("test dynamic item", t, func(ctx convey.C) {
  41. mid := int64(27515256)
  42. dyID := int64(118606711587078278)
  43. data, err := d.Dynamic(context.Background(), mid, dyID, 16)
  44. convey.So(err, convey.ShouldBeNil)
  45. convey.Printf("%+v", data)
  46. })
  47. }