dialog_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. "go-common/app/admin/main/vip/model"
  8. xtime "go-common/library/time"
  9. "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestDaoDialogSave(t *testing.T) {
  12. curr := xtime.Time(time.Now().Unix())
  13. convey.Convey("DialogSave", t, func() {
  14. dlg := &model.ConfDialog{ID: 1, StartTime: curr, Operator: "tommy"}
  15. eff, err := d.DialogSave(context.TODO(), dlg)
  16. convey.So(err, convey.ShouldBeNil)
  17. convey.So(eff, convey.ShouldNotBeNil)
  18. })
  19. convey.Convey("DialogByID", t, func() {
  20. dlg, err := d.DialogByID(context.TODO(), 1)
  21. convey.So(err, convey.ShouldBeNil)
  22. convey.So(dlg, convey.ShouldNotBeNil)
  23. })
  24. convey.Convey("DialogEnable", t, func() {
  25. dlg := &model.ConfDialog{ID: 1, Stage: false}
  26. eff, err := d.DialogEnable(context.TODO(), dlg)
  27. convey.So(err, convey.ShouldBeNil)
  28. convey.So(eff, convey.ShouldNotBeNil)
  29. })
  30. convey.Convey("DialogEnable", t, func() {
  31. dlg := &model.ConfDialog{ID: 1, Stage: true}
  32. eff, err := d.DialogEnable(context.TODO(), dlg)
  33. convey.So(err, convey.ShouldBeNil)
  34. convey.So(eff, convey.ShouldNotBeNil)
  35. })
  36. convey.Convey("DialogAll", t, func() {
  37. res, err := d.DialogAll(context.TODO(), 0, 0, "active")
  38. convey.So(err, convey.ShouldBeNil)
  39. convey.So(res, convey.ShouldNotBeNil)
  40. })
  41. }
  42. func TestDaoCountDialogByPlatID(t *testing.T) {
  43. convey.Convey("TestDaoCountDialogByPlatID", t, func() {
  44. res, err := d.CountDialogByPlatID(context.TODO(), 1)
  45. fmt.Println(res)
  46. convey.So(err, convey.ShouldBeNil)
  47. convey.So(res, convey.ShouldBeGreaterThanOrEqualTo, 0)
  48. })
  49. }