list_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_List(t *testing.T) {
  8. Convey("get data", t, func() {
  9. res, err := s.dao.List(context.TODO(), 1)
  10. So(err, ShouldBeNil)
  11. So(res, ShouldNotBeEmpty)
  12. })
  13. Convey("list not exist", t, func() {
  14. res, err := s.dao.List(context.TODO(), 999)
  15. So(err, ShouldBeNil)
  16. So(res, ShouldBeNil)
  17. })
  18. }
  19. func Test_rawListArticles(t *testing.T) {
  20. Convey("get data", t, func() {
  21. res, err := s.rawListArticles(context.TODO(), 1)
  22. So(err, ShouldBeNil)
  23. So(res, ShouldNotBeEmpty)
  24. })
  25. }
  26. func Test_ListInfo(t *testing.T) {
  27. Convey("get data", t, func() {
  28. res, err := s.ListInfo(context.TODO(), 821)
  29. So(err, ShouldBeNil)
  30. So(res, ShouldNotBeEmpty)
  31. })
  32. Convey("null data", t, func() {
  33. res, err := s.ListInfo(context.TODO(), 999999999)
  34. So(err, ShouldNotBeNil)
  35. So(res, ShouldBeNil)
  36. })
  37. }
  38. func Test_Lists(t *testing.T) {
  39. Convey("get data", t, func() {
  40. res, err := s.Lists(context.TODO(), []int64{3})
  41. So(err, ShouldBeNil)
  42. So(res, ShouldNotBeEmpty)
  43. So(res[3].ImageURL, ShouldNotBeEmpty)
  44. })
  45. Convey("null data", t, func() {
  46. res, err := s.Lists(context.TODO(), []int64{})
  47. So(err, ShouldBeNil)
  48. So(res, ShouldBeEmpty)
  49. })
  50. }