protect_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 TestDanmuProtectApplyList(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. mid = int64(2089809)
  12. page = int64(0)
  13. aidStr = "1"
  14. sort = "ctime"
  15. ip = "127.0.0.1"
  16. )
  17. convey.Convey("ProtectApplyList", t, func(ctx convey.C) {
  18. result, err := d.ProtectApplyList(c, mid, page, aidStr, sort, ip)
  19. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(result, convey.ShouldNotBeNil)
  22. })
  23. })
  24. }
  25. func TestDanmuProtectApplyVideoList(t *testing.T) {
  26. var (
  27. c = context.TODO()
  28. mid = int64(2089809)
  29. ip = "127.0.0.1"
  30. )
  31. convey.Convey("ProtectApplyVideoList", t, func(ctx convey.C) {
  32. result, err := d.ProtectApplyVideoList(c, mid, ip)
  33. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(result, convey.ShouldNotBeNil)
  36. })
  37. })
  38. }
  39. func TestDanmuProtectOper(t *testing.T) {
  40. var (
  41. c = context.TODO()
  42. mid = int64(2089809)
  43. status = int64(0)
  44. ids = "1,2"
  45. ip = "127.0.0.1"
  46. )
  47. convey.Convey("ProtectOper", t, func(ctx convey.C) {
  48. defer gock.OffAll()
  49. httpMock("POST", d.dmProtectApplyStatusURL).Reply(200).JSON(`{"code":20043,"data":""}`)
  50. err := d.ProtectOper(c, mid, status, ids, ip)
  51. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldNotBeNil)
  53. })
  54. })
  55. }