draft_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package article
  2. import (
  3. "context"
  4. "testing"
  5. artMdl "go-common/app/interface/main/creative/model/article"
  6. "go-common/library/ecode"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestArticleAddDraft(t *testing.T) {
  10. var (
  11. c = context.TODO()
  12. art = &artMdl.ArtParam{}
  13. )
  14. convey.Convey("AddDraft", t, func(ctx convey.C) {
  15. id, err := d.AddDraft(c, art)
  16. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldNotEqual, ecode.ArtCreationNoPrivilege)
  18. ctx.So(id, convey.ShouldEqual, 0)
  19. })
  20. })
  21. }
  22. func TestArticleDelDraft(t *testing.T) {
  23. var (
  24. c = context.TODO()
  25. aid = int64(1)
  26. mid = int64(0)
  27. ip = ""
  28. )
  29. convey.Convey("DelDraft", t, func(ctx convey.C) {
  30. err := d.DelDraft(c, aid, mid, ip)
  31. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldNotEqual, ecode.ArtCreationNoPrivilege)
  33. })
  34. })
  35. }
  36. func TestArticleDraft(t *testing.T) {
  37. var (
  38. c = context.TODO()
  39. aid = int64(0)
  40. mid = int64(0)
  41. ip = ""
  42. )
  43. convey.Convey("Draft", t, func(ctx convey.C) {
  44. res, err := d.Draft(c, aid, mid, ip)
  45. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  46. ctx.So(err, convey.ShouldNotEqual, ecode.ArtCreationNoPrivilege)
  47. ctx.So(res, convey.ShouldBeNil)
  48. })
  49. })
  50. }
  51. func TestArticleDrafts(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. mid = int64(0)
  55. pn = int(0)
  56. ps = int(0)
  57. ip = ""
  58. )
  59. convey.Convey("Drafts", t, func(ctx convey.C) {
  60. res, err := d.Drafts(c, mid, pn, ps, ip)
  61. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldNotEqual, ecode.ArtCreationNoPrivilege)
  63. ctx.So(res, convey.ShouldBeNil)
  64. })
  65. })
  66. }