report_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package danmu
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. gock "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestDanmuReportUpList(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. mid = int64(2089809)
  12. pn = int64(1)
  13. ps = int64(10)
  14. aidStr = "1"
  15. ip = "127.0.0.1"
  16. )
  17. convey.Convey("ReportUpList", t, func(ctx convey.C) {
  18. defer gock.OffAll()
  19. httpMock("GET", d.dmReportUpListURL).Reply(200).JSON(`{"code":20043,"data":""}`)
  20. result, total, err := d.ReportUpList(c, mid, pn, ps, aidStr, ip)
  21. ctx.Convey("Then err should be nil.result,total should not be nil.", func(ctx convey.C) {
  22. ctx.So(err, convey.ShouldNotBeNil)
  23. ctx.So(total, convey.ShouldNotBeNil)
  24. ctx.So(result, convey.ShouldNotBeNil)
  25. })
  26. })
  27. }
  28. func TestDanmuReportUpArchives(t *testing.T) {
  29. var (
  30. c = context.TODO()
  31. mid = int64(2089809)
  32. ip = "127.0.0.1"
  33. )
  34. convey.Convey("ReportUpArchives", t, func(ctx convey.C) {
  35. defer gock.OffAll()
  36. httpMock("GET", d.dmReportUpArchivesURL).Reply(200).JSON(`{"code":20043,"data":""}`)
  37. ars, err := d.ReportUpArchives(c, mid, ip)
  38. ctx.Convey("Then err should be nil.ars should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldNotBeNil)
  40. ctx.So(ars, convey.ShouldNotBeNil)
  41. })
  42. })
  43. }
  44. func TestDanmuReportUpEdit(t *testing.T) {
  45. var (
  46. c = context.TODO()
  47. mid = int64(2089809)
  48. dmid = int64(1)
  49. cid = int64(1)
  50. op = int64(0)
  51. ip = "127.0.0.1"
  52. )
  53. convey.Convey("ReportUpEdit", t, func(ctx convey.C) {
  54. defer gock.OffAll()
  55. httpMock("POST", d.dmReportUpArchivesURL).Reply(200).JSON(`{"code":20043,"data":""}`)
  56. err := d.ReportUpEdit(c, mid, dmid, cid, op, ip)
  57. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldNotBeNil)
  59. })
  60. })
  61. }