config_test.go 841 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/reply/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestConfig(t *testing.T) {
  9. var (
  10. m = &model.Config{
  11. Oid: 1,
  12. Type: 4,
  13. ShowEntry: 1,
  14. ShowAdmin: 1,
  15. }
  16. c = context.Background()
  17. )
  18. Convey("test config ", t, WithService(func(s *Service) {
  19. _, err := s.AddReplyConfig(c, m)
  20. So(err, ShouldBeNil)
  21. cfg, err := s.LoadReplyConfig(c, m.Type, m.Category, m.Oid)
  22. So(err, ShouldBeNil)
  23. So(cfg, ShouldNotBeNil)
  24. list, total, pages, err := s.PaginateReplyConfig(c, m.Type, m.Category, m.Oid, "", 0, 10)
  25. So(err, ShouldBeNil)
  26. So(len(list), ShouldNotEqual, 0)
  27. So(total, ShouldNotEqual, 0)
  28. So(pages, ShouldNotEqual, 0)
  29. ok, err := s.RenewReplyConfig(c, cfg.ID)
  30. So(err, ShouldBeNil)
  31. So(ok, ShouldEqual, true)
  32. }))
  33. }