subject_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package like
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. "gopkg.in/h2non/gock.v1"
  8. )
  9. func TestLikeSubject(t *testing.T) {
  10. convey.Convey("Subject", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. sid = int64(10193)
  14. )
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. n, err := d.Subject(c, sid)
  17. ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(n, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestLikeInOnlinelog(t *testing.T) {
  25. convey.Convey("InOnlinelog", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. sid = int64(10193)
  29. aid = int64(1)
  30. stage = int64(1)
  31. yes = int64(1)
  32. no = int64(1)
  33. )
  34. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  35. rows, err := d.InOnlinelog(c, sid, aid, stage, yes, no)
  36. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(rows, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestLikeSubjectList(t *testing.T) {
  44. convey.Convey("SubjectList", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. types = []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 13, 15, 16, 17, 18, 19}
  48. ts = time.Now()
  49. )
  50. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  51. res, err := d.SubjectList(c, types, ts)
  52. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. ctx.So(res, convey.ShouldNotBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestLikeSubjectTotalStat(t *testing.T) {
  60. convey.Convey("SubjectTotalStat", t, func(ctx convey.C) {
  61. var (
  62. c = context.Background()
  63. sid = int64(10338)
  64. )
  65. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  66. rs, err := d.SubjectTotalStat(c, sid)
  67. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. ctx.So(rs, convey.ShouldNotBeNil)
  70. })
  71. })
  72. })
  73. }
  74. func TestLikeAddLotteryTimes(t *testing.T) {
  75. convey.Convey("AddLotteryTimes", t, func(ctx convey.C) {
  76. var (
  77. c = context.Background()
  78. sid = int64(315)
  79. mid = int64(1)
  80. )
  81. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  82. defer gock.OffAll()
  83. httpMock("GET", d.addLotteryTimesURL).Reply(200).SetHeaders(map[string]string{
  84. "Code": "0",
  85. })
  86. err := d.AddLotteryTimes(c, sid, mid)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }