dao_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package creative
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/interface/main/app-view/conf"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. d *Dao
  12. )
  13. func TestMain(m *testing.M) {
  14. if os.Getenv("DEPLOY_ENV") != "" {
  15. flag.Set("app_id", "main.app-svr.app-view")
  16. flag.Set("conf_token", "3a4CNLBhdFbRQPs7B4QftGvXHtJo92xw")
  17. flag.Set("tree_id", "4575")
  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. }
  25. flag.Parse()
  26. if err := conf.Init(); err != nil {
  27. panic(err)
  28. }
  29. d = New(conf.Conf)
  30. m.Run()
  31. os.Exit(0)
  32. }
  33. func TestMovie(t *testing.T) {
  34. var (
  35. c = context.TODO()
  36. vmid = int64(0)
  37. )
  38. convey.Convey("Movie", t, func(ctx convey.C) {
  39. _, err := d.FollowSwitch(c, vmid)
  40. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  41. err = nil
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. }
  46. func TestBgm(t *testing.T) {
  47. var (
  48. c = context.TODO()
  49. aid = int64(10110995)
  50. cid = int64(10135146)
  51. )
  52. convey.Convey("Bgm", t, func(ctx convey.C) {
  53. _, err := d.Bgm(c, aid, cid)
  54. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  55. err = nil
  56. ctx.So(err, convey.ShouldBeNil)
  57. })
  58. })
  59. }
  60. func TestPoints(t *testing.T) {
  61. var (
  62. c = context.TODO()
  63. aid = int64(10110995)
  64. cid = int64(10135146)
  65. )
  66. convey.Convey("Points", t, func(ctx convey.C) {
  67. _, err := d.Points(c, aid, cid)
  68. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  69. err = nil
  70. ctx.So(err, convey.ShouldBeNil)
  71. })
  72. })
  73. }
  74. func TestSpecial(t *testing.T) {
  75. convey.Convey("Special", t, func(ctx convey.C) {
  76. midsM, err := d.Special(context.Background())
  77. ctx.So(err, convey.ShouldBeNil)
  78. ctx.Println(midsM)
  79. })
  80. }