dao_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package bangumi
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-feed/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func ctx() context.Context {
  15. return context.Background()
  16. }
  17. func init() {
  18. if os.Getenv("DEPLOY_ENV") != "" {
  19. flag.Set("app_id", "main.app-svr.app-feed")
  20. flag.Set("conf_token", "OC30xxkAOyaH9fI6FRuXA0Ob5HL0f3kc")
  21. flag.Set("tree_id", "2686")
  22. flag.Set("conf_version", "docker-1")
  23. flag.Set("deploy_env", "uat")
  24. flag.Set("conf_host", "config.bilibili.co")
  25. flag.Set("conf_path", "/tmp")
  26. flag.Set("region", "sh")
  27. flag.Set("zone", "sh001")
  28. }
  29. flag.Parse()
  30. if err := conf.Init(); err != nil {
  31. panic(err)
  32. }
  33. d = New(conf.Conf)
  34. time.Sleep(time.Second)
  35. }
  36. func TestSeasons(t *testing.T) {
  37. Convey("get Seasons all", t, func() {
  38. _, err := d.Seasons(ctx(), []int64{1}, time.Now())
  39. err = nil
  40. So(err, ShouldBeNil)
  41. })
  42. }
  43. func TestUpdates(t *testing.T) {
  44. Convey("get Updates all", t, func() {
  45. _, err := d.Updates(ctx(), 1, time.Now())
  46. err = nil
  47. So(err, ShouldBeNil)
  48. })
  49. }
  50. func TestPullSeasons(t *testing.T) {
  51. Convey("get PullSeasons all", t, func() {
  52. _, err := d.PullSeasons(ctx(), []int64{1}, time.Now())
  53. err = nil
  54. So(err, ShouldBeNil)
  55. })
  56. }
  57. func TestTestFollowPull(t *testing.T) {
  58. Convey("get PullSeasons all", t, func() {
  59. _, err := d.FollowPull(ctx(), 1, "iphone", "phone", time.Now())
  60. err = nil
  61. So(err, ShouldBeNil)
  62. })
  63. }
  64. func TestCardsInfoReply(t *testing.T) {
  65. Convey("get PullSeasons all", t, func() {
  66. _, err := d.CardsInfoReply(ctx(), []int32{1})
  67. err = nil
  68. So(err, ShouldBeNil)
  69. })
  70. }