mysql_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package weeklyhonor
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestWeeklyhonorpingMySQL(t *testing.T) {
  8. convey.Convey("pingMySQL", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. err := d.pingMySQL(c)
  14. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestWeeklyhonorHonorLogs(t *testing.T) {
  21. convey.Convey("HonorLogs", t, func(ctx convey.C) {
  22. var (
  23. c = context.Background()
  24. mid = int64(2)
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. _, err := d.HonorLogs(c, mid)
  28. ctx.Convey("Then err should be nil.hls should not be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestWeeklyhonorLatestHonorLogs(t *testing.T) {
  35. convey.Convey("LatestHonorLogs", t, func(ctx convey.C) {
  36. var (
  37. c = context.Background()
  38. mids = []int64{1}
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. _, err := d.LatestHonorLogs(c, mids)
  42. ctx.Convey("Then err should be nil.hls should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestWeeklyhonorUpsertCount(t *testing.T) {
  49. convey.Convey("UpsertCount", t, func(ctx convey.C) {
  50. var (
  51. c = context.Background()
  52. mid = int64(0)
  53. hid = int(0)
  54. )
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. affected, err := d.UpsertCount(c, mid, hid)
  57. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. ctx.So(affected, convey.ShouldNotBeNil)
  60. })
  61. })
  62. })
  63. }
  64. func TestWeeklyhonorClickCounts(t *testing.T) {
  65. convey.Convey("ClickCounts", t, func(ctx convey.C) {
  66. var (
  67. c = context.Background()
  68. mids = []int64{1}
  69. )
  70. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  71. res, err := d.ClickCounts(c, mids)
  72. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. ctx.So(res, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }