tips_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package service
  2. import (
  3. "testing"
  4. "go-common/app/admin/main/vip/model"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. // go test -test.v -test.run TestServiceTipList
  8. func TestServiceTipList(t *testing.T) {
  9. Convey("TestServiceTipList", t, func() {
  10. var (
  11. platform = int8(0)
  12. state = int8(0)
  13. position = int8(2)
  14. )
  15. res, err := s.TipList(c, platform, state, position)
  16. for _, v := range res {
  17. t.Logf("%+v", v)
  18. }
  19. So(len(res) != 0, ShouldBeTrue)
  20. So(err, ShouldBeNil)
  21. })
  22. }
  23. // go test -test.v -test.run TestServiceTipByID
  24. func TestServiceTipByID(t *testing.T) {
  25. Convey("TestServiceTipByID", t, func() {
  26. var (
  27. id int64 = 1
  28. )
  29. res, err := s.TipByID(c, id)
  30. t.Logf("%+v", res)
  31. So(err, ShouldBeNil)
  32. })
  33. }
  34. // go test -test.v -test.run TestServiceAddTip
  35. func TestServiceAddTip(t *testing.T) {
  36. Convey("TestServiceAddTip", t, func() {
  37. t := &model.Tips{
  38. Platform: 2,
  39. Version: 4000,
  40. Tip: "一样",
  41. Link: "http://www.baidu.com",
  42. StartTime: 1528315928,
  43. EndTime: 1538315928,
  44. Level: 2,
  45. JudgeType: 1,
  46. Operator: "baihai",
  47. Position: 2,
  48. }
  49. err := s.AddTip(c, t)
  50. So(err, ShouldBeNil)
  51. })
  52. }
  53. // go test -test.v -test.run TestServiceUpdateTip
  54. func TestServiceUpdateTip(t *testing.T) {
  55. Convey("TestServiceUpdateTip", t, func() {
  56. t := &model.Tips{
  57. ID: 1,
  58. Platform: 2,
  59. Version: 4000,
  60. Tip: "一样2",
  61. Link: "http://www.baidu.com",
  62. StartTime: 1528315928,
  63. EndTime: 1538315928,
  64. Level: 2,
  65. JudgeType: 1,
  66. Position: 1,
  67. Operator: "baihai",
  68. }
  69. err := s.TipUpdate(c, t)
  70. So(err, ShouldBeNil)
  71. })
  72. }
  73. // go test -test.v -test.run TestServiceDeleteTip
  74. func TestServiceDeleteTip(t *testing.T) {
  75. Convey("TestServiceDeleteTip", t, func() {
  76. var (
  77. id int64 = 2
  78. )
  79. err := s.DeleteTip(c, id, "baihai")
  80. So(err, ShouldBeNil)
  81. })
  82. }
  83. // go test -test.v -test.run TestServiceExpireTip
  84. func TestServiceExpireTip(t *testing.T) {
  85. Convey("TestServiceExpireTip", t, func() {
  86. var (
  87. id int64 = 3
  88. )
  89. err := s.ExpireTip(c, id, "baihai")
  90. So(err, ShouldBeNil)
  91. })
  92. }