push_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/vip/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAddPushData(t *testing.T) {
  9. var (
  10. id int64
  11. err error
  12. )
  13. convey.Convey("AddPushData", t, func() {
  14. id, err = d.AddPushData(context.TODO(), &model.VipPushData{Title: "test push"})
  15. convey.So(err, convey.ShouldBeNil)
  16. convey.So(id, convey.ShouldNotBeNil)
  17. })
  18. convey.Convey("GetPushData", t, func() {
  19. r, err := d.GetPushData(context.TODO(), id)
  20. convey.So(err, convey.ShouldBeNil)
  21. convey.So(r, convey.ShouldNotBeNil)
  22. })
  23. convey.Convey("UpdatePushData", t, func() {
  24. eff, err := d.UpdatePushData(context.TODO(), &model.VipPushData{ID: id, Title: "push test"})
  25. convey.So(err, convey.ShouldBeNil)
  26. convey.So(eff, convey.ShouldNotBeNil)
  27. })
  28. convey.Convey("PushDataCount", t, func() {
  29. count, err := d.PushDataCount(context.TODO(), &model.ArgPushData{})
  30. convey.So(err, convey.ShouldBeNil)
  31. convey.So(count, convey.ShouldNotBeNil)
  32. })
  33. convey.Convey("PushDatas", t, func() {
  34. res, err := d.PushDatas(context.TODO(), &model.ArgPushData{})
  35. convey.So(err, convey.ShouldBeNil)
  36. convey.So(res, convey.ShouldNotBeNil)
  37. })
  38. convey.Convey("DisablePushData", t, func() {
  39. err := d.DisablePushData(context.TODO(), &model.VipPushData{ID: id, Title: "push test"})
  40. convey.So(err, convey.ShouldBeNil)
  41. })
  42. convey.Convey("DelPushData", t, func() {
  43. err := d.DelPushData(context.TODO(), id)
  44. convey.So(err, convey.ShouldBeNil)
  45. })
  46. }