official_test.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestOfficial(t *testing.T) {
  9. convey.Convey("Official", t, func() {
  10. o, err := d.Official(context.Background(), 123)
  11. convey.So(err, convey.ShouldBeNil)
  12. convey.So(o, convey.ShouldNotBeNil)
  13. })
  14. }
  15. func TestOfficialEdit(t *testing.T) {
  16. convey.Convey("OfficialEdit", t, func() {
  17. o, err := d.OfficialEdit(context.Background(), 123, 1, "title", "desc")
  18. convey.So(err, convey.ShouldBeNil)
  19. convey.So(o, convey.ShouldNotBeNil)
  20. })
  21. }
  22. func TestOfficials(t *testing.T) {
  23. convey.Convey("Officials", t, func() {
  24. o, total, err := d.Officials(context.Background(), 123, []int8{1}, time.Time{}, time.Now(), 1, 20)
  25. convey.So(err, convey.ShouldBeNil)
  26. convey.So(o, convey.ShouldNotBeNil)
  27. convey.So(total, convey.ShouldBeGreaterThan, 0)
  28. })
  29. }
  30. func TestOfficialDoc(t *testing.T) {
  31. convey.Convey("OfficialDoc", t, func() {
  32. o, err := d.OfficialDoc(context.Background(), 123)
  33. convey.So(err, convey.ShouldBeNil)
  34. convey.So(o, convey.ShouldNotBeNil)
  35. })
  36. }
  37. func TestOfficialDocs(t *testing.T) {
  38. convey.Convey("OfficialDocs", t, func() {
  39. o, total, err := d.OfficialDocs(context.Background(), 123, []int8{1}, []int8{1}, "", time.Time{}, time.Now(), 1, 20)
  40. convey.So(err, convey.ShouldBeNil)
  41. convey.So(o, convey.ShouldNotBeNil)
  42. convey.So(total, convey.ShouldBeGreaterThan, 0)
  43. })
  44. }
  45. func TestOfficialDocAudit(t *testing.T) {
  46. convey.Convey("OfficialDocAudit", t, func() {
  47. err := d.OfficialDocAudit(context.Background(), 123, 1, "guan", true, "")
  48. convey.So(err, convey.ShouldBeNil)
  49. })
  50. }
  51. func TestOfficialDocEdit(t *testing.T) {
  52. convey.Convey("OfficialDocEdit", t, func() {
  53. err := d.OfficialDocEdit(context.Background(), 123, "guan", 1, 1, "title", "desc", "extra", "12121", true)
  54. convey.So(err, convey.ShouldBeNil)
  55. })
  56. }
  57. func TestOfficialDocsByMids(t *testing.T) {
  58. convey.Convey("OfficialDocsByMids", t, func() {
  59. res, err := d.OfficialDocsByMids(context.Background(), []int64{2, 3, 10, 12})
  60. convey.So(err, convey.ShouldBeNil)
  61. convey.So(len(res), convey.ShouldBeGreaterThan, 0)
  62. })
  63. }
  64. func TestOfficialDocSubmit(t *testing.T) {
  65. convey.Convey("OfficialDocSubmit", t, func() {
  66. err := d.OfficialDocSubmit(context.Background(), 123, "guan", 1, 1, "title", "desc", "extra", "12121", true, "admin")
  67. convey.So(err, convey.ShouldBeNil)
  68. })
  69. }