moral_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/member/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoMoralLog(t *testing.T) {
  9. var (
  10. c = context.Background()
  11. mid = int64(4780461)
  12. // ip = ""
  13. )
  14. convey.Convey("MoralLog", t, func(ctx convey.C) {
  15. p1, p2 := d.MoralLog(c, mid)
  16. ctx.Convey("Error should be nil", func(ctx convey.C) {
  17. ctx.So(p2, convey.ShouldBeNil)
  18. })
  19. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  20. ctx.So(p1, convey.ShouldNotBeNil)
  21. })
  22. })
  23. }
  24. func TestDaoMoralLogByID(t *testing.T) {
  25. var (
  26. c = context.Background()
  27. logID = "test"
  28. // ip = ""
  29. )
  30. convey.Convey("MoralLogByID", t, func(ctx convey.C) {
  31. p1, p2 := d.MoralLogByID(c, logID)
  32. ctx.Convey("Error should be nil", func(ctx convey.C) {
  33. ctx.So(p2, convey.ShouldEqual, -404)
  34. })
  35. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  36. ctx.So(p1, convey.ShouldBeNil)
  37. })
  38. })
  39. }
  40. func TestDaoDeleteMoralLog(t *testing.T) {
  41. var (
  42. c = context.Background()
  43. logID = "test"
  44. // ip = ""
  45. )
  46. convey.Convey("DeleteMoralLog", t, func(ctx convey.C) {
  47. p1 := d.DeleteMoralLog(c, logID)
  48. ctx.Convey("Error should be nil", func(ctx convey.C) {
  49. ctx.So(p1, convey.ShouldBeNil)
  50. })
  51. })
  52. }
  53. func TestDaodeleteLogReport(t *testing.T) {
  54. var (
  55. c = context.Background()
  56. business = int(0)
  57. logID = "test"
  58. ip = ""
  59. )
  60. convey.Convey("deleteLogReport", t, func(ctx convey.C) {
  61. p1 := d.deleteLogReport(c, business, logID, ip)
  62. ctx.Convey("Error should be nil", func(ctx convey.C) {
  63. ctx.So(p1, convey.ShouldBeNil)
  64. })
  65. })
  66. }
  67. func TestDaoasMoralLog(t *testing.T) {
  68. var (
  69. res = &model.SearchResult{}
  70. )
  71. convey.Convey("asMoralLog", t, func(ctx convey.C) {
  72. p1 := asMoralLog(res)
  73. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  74. ctx.So(p1, convey.ShouldNotBeNil)
  75. })
  76. })
  77. }
  78. func TestDaoMoral(t *testing.T) {
  79. var (
  80. c = context.Background()
  81. mid = int64(4780461)
  82. )
  83. convey.Convey("Moral", t, func(ctx convey.C) {
  84. moral, err := d.Moral(c, mid)
  85. ctx.Convey("Error should be nil", func(ctx convey.C) {
  86. ctx.So(err, convey.ShouldBeNil)
  87. })
  88. ctx.Convey("moral should not be nil", func(ctx convey.C) {
  89. ctx.So(moral, convey.ShouldNotBeNil)
  90. })
  91. })
  92. }