mysql_recommend_test.go 863 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_RecommendByCategory(t *testing.T) {
  9. Convey("get data", t, WithMysql(func(d *Dao) {
  10. res, err := d.RecommendByCategory(context.TODO(), 0)
  11. So(err, ShouldBeNil)
  12. So(res, ShouldNotBeEmpty)
  13. }))
  14. Convey("no data", t, WithMysql(func(d *Dao) {
  15. res, err := d.RecommendByCategory(context.TODO(), 1000)
  16. So(err, ShouldBeNil)
  17. So(res, ShouldBeEmpty)
  18. }))
  19. }
  20. func Test_AllRecommendCount(t *testing.T) {
  21. Convey("get data", t, func() {
  22. res, err := d.AllRecommendCount(context.TODO(), time.Now())
  23. So(err, ShouldBeNil)
  24. So(res, ShouldBeGreaterThan, 0)
  25. })
  26. }
  27. func Test_AllRecommends(t *testing.T) {
  28. Convey("get data", t, func() {
  29. res, err := d.AllRecommends(context.TODO(), time.Now(), 1, 5)
  30. So(err, ShouldBeNil)
  31. So(res, ShouldNotBeEmpty)
  32. })
  33. }