tips_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/vip/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoTipList(t *testing.T) {
  9. convey.Convey("TipList", t, func() {
  10. rs, err := d.TipList(context.TODO(), 0, 0, 0, 0)
  11. convey.So(err, convey.ShouldBeNil)
  12. convey.So(rs, convey.ShouldNotBeNil)
  13. })
  14. }
  15. func TestDaoAddTip(t *testing.T) {
  16. var (
  17. id int64
  18. err error
  19. )
  20. convey.Convey("AddTip", t, func() {
  21. id, err = d.AddTip(context.TODO(), &model.Tips{Tip: "test"})
  22. convey.So(err, convey.ShouldBeNil)
  23. convey.So(id, convey.ShouldNotBeNil)
  24. })
  25. convey.Convey("TipByID", t, func() {
  26. r, err := d.TipByID(context.TODO(), id)
  27. convey.So(err, convey.ShouldBeNil)
  28. convey.So(r, convey.ShouldNotBeNil)
  29. })
  30. convey.Convey("TipUpdate", t, func() {
  31. eff, err := d.TipUpdate(context.TODO(), &model.Tips{ID: id, Tip: "test"})
  32. convey.So(err, convey.ShouldBeNil)
  33. convey.So(eff, convey.ShouldNotBeNil)
  34. })
  35. convey.Convey("ExpireTip", t, func() {
  36. eff, err := d.ExpireTip(context.TODO(), id, "", 0)
  37. convey.So(err, convey.ShouldBeNil)
  38. convey.So(eff, convey.ShouldNotBeNil)
  39. })
  40. convey.Convey("DeleteTip", t, func() {
  41. eff, err := d.DeleteTip(context.TODO(), id, 0, "")
  42. convey.So(err, convey.ShouldBeNil)
  43. convey.So(eff, convey.ShouldNotBeNil)
  44. })
  45. }