dao_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package history
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-interface/conf"
  5. "testing"
  6. "flag"
  7. "path/filepath"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var d *Dao
  11. func init() {
  12. dir, _ := filepath.Abs("../cmd/app-interface-test.toml")
  13. flag.Set("conf", dir)
  14. conf.Init()
  15. d = New(conf.Conf)
  16. }
  17. func WithDao(f func(d *Dao)) func() {
  18. return func() {
  19. Reset(func() {})
  20. f(d)
  21. }
  22. }
  23. func TestDao_ArchiveInfo(t *testing.T) {
  24. Convey("ArchiveInfo", t, WithDao(func(d *Dao) {
  25. _, err := d.Archive(context.TODO(), []int64{1, 2})
  26. So(err, ShouldBeNil)
  27. }))
  28. }
  29. func TestDao_ArticleInfo(t *testing.T) {
  30. Convey("ArticleInfo", t, WithDao(func(d *Dao) {
  31. _, err := d.Article(context.TODO(), []int64{1, 2})
  32. So(err, ShouldBeNil)
  33. }))
  34. }
  35. func TestDao_PGCInfo(t *testing.T) {
  36. Convey("PGCInfo", t, WithDao(func(d *Dao) {
  37. _, err := d.PGC(context.TODO(), "1", "1", 111, 27515256)
  38. So(err, ShouldBeNil)
  39. }))
  40. }
  41. func TestDao_GetList(t *testing.T) {
  42. Convey("GetList", t, WithDao(func(d *Dao) {
  43. _, err := d.History(context.TODO(), 27515256, 1, 20)
  44. So(err, ShouldBeNil)
  45. }))
  46. }