dao_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package upper
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/interface/main/app-feed/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. d *Dao
  12. )
  13. func init() {
  14. if os.Getenv("DEPLOY_ENV") != "" {
  15. flag.Set("app_id", "main.app-svr.app-feed")
  16. flag.Set("conf_token", "OC30xxkAOyaH9fI6FRuXA0Ob5HL0f3kc")
  17. flag.Set("tree_id", "2686")
  18. flag.Set("conf_version", "docker-1")
  19. flag.Set("deploy_env", "uat")
  20. flag.Set("conf_host", "config.bilibili.co")
  21. flag.Set("conf_path", "/tmp")
  22. flag.Set("region", "sh")
  23. flag.Set("zone", "sh001")
  24. } else {
  25. flag.Set("conf", "../../cmd/app-feed-test.toml")
  26. }
  27. flag.Parse()
  28. if err := conf.Init(); err != nil {
  29. panic(err)
  30. }
  31. d = New(conf.Conf)
  32. }
  33. func Test_Feed(t *testing.T) {
  34. Convey("should get Feed", t, func() {
  35. _, err := d.Feed(context.Background(), 1, 2, 3)
  36. So(err, ShouldBeNil)
  37. })
  38. }
  39. func Test_ArchiveFeed(t *testing.T) {
  40. Convey("should get ArchiveFeed", t, func() {
  41. _, err := d.ArchiveFeed(context.Background(), 1, 2, 3)
  42. So(err, ShouldBeNil)
  43. })
  44. }
  45. func Test_BangumiFeed(t *testing.T) {
  46. Convey("should get BangumiFeed", t, func() {
  47. _, err := d.BangumiFeed(context.Background(), 1, 2, 3)
  48. So(err, ShouldBeNil)
  49. })
  50. }
  51. func Test_Recent(t *testing.T) {
  52. Convey("should get Recent", t, func() {
  53. _, err := d.Recent(context.Background(), 1, 2)
  54. So(err, ShouldBeNil)
  55. })
  56. }
  57. func Test_ArticleFeed(t *testing.T) {
  58. Convey("should get ArticleFeed", t, func() {
  59. _, err := d.ArticleFeed(context.Background(), 1, 2, 3)
  60. So(err, ShouldBeNil)
  61. })
  62. }
  63. func Test_ArticleUnreadCount(t *testing.T) {
  64. Convey("should get ArticleUnreadCount", t, func() {
  65. _, err := d.ArticleUnreadCount(context.Background(), 1)
  66. So(err, ShouldBeNil)
  67. })
  68. }