dao_test.go 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package ad
  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 TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.app-svr.app-feed")
  17. flag.Set("conf_token", "OC30xxkAOyaH9fI6FRuXA0Ob5HL0f3kc")
  18. flag.Set("tree_id", "2686")
  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-view-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 TestAd(t *testing.T) {
  36. Convey("TestAd", t, func(ctx C) {
  37. gotAdvert, err := d.Ad(context.Background(), 121212, 0, "", []int64{1221}, "", "", "", "", "", "", "", "", 1, time.Now())
  38. So(gotAdvert, ShouldNotBeNil)
  39. So(err, ShouldBeNil)
  40. })
  41. }