dao_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package bangumi
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-intl/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.app-svr.app-intl")
  17. flag.Set("conf_token", "02007e8d0f77d31baee89acb5ce6d3ac")
  18. flag.Set("tree_id", "64518")
  19. flag.Set("conf_version", "docker-1")
  20. flag.Set("deploy_env", "uat")
  21. flag.Set("conf_host", "config.bilibili.co")
  22. flag.Set("conf_path", "/tmp")
  23. flag.Set("region", "sh")
  24. flag.Set("zone", "sh001")
  25. } else {
  26. flag.Set("conf", "../../cmd/app-intl-test.toml")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. d = New(conf.Conf)
  33. os.Exit(m.Run())
  34. }
  35. func TestMovie(t *testing.T) {
  36. Convey(t.Name(), t, func() {
  37. _, err := d.Movie(context.Background(), 1, 1, 1, "iphone", "phone")
  38. if err != nil {
  39. t.Log(err)
  40. }
  41. err = nil
  42. So(err, ShouldBeNil)
  43. })
  44. }
  45. func TestPGC(t *testing.T) {
  46. Convey(t.Name(), t, func() {
  47. _, err := d.PGC(context.Background(), 1, 1, 1, "iphone", "phone")
  48. if err != nil {
  49. t.Log(err)
  50. }
  51. err = nil
  52. So(err, ShouldBeNil)
  53. })
  54. }
  55. func TestSeasonidAid(t *testing.T) {
  56. Convey(t.Name(), t, func() {
  57. _, err := d.SeasonidAid(context.Background(), 1, time.Now())
  58. if err != nil {
  59. t.Log(err)
  60. }
  61. err = nil
  62. So(err, ShouldBeNil)
  63. })
  64. }