dao_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "path/filepath"
  7. "testing"
  8. "go-common/app/job/main/push/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var d *Dao
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") == "uat" {
  14. flag.Set("app_id", "main.web-svr.push-job")
  15. flag.Set("conf_token", "4de43ccf842485eea314fd8a48f1ee84")
  16. flag.Set("tree_id", "5220")
  17. flag.Set("conf_version", "docker-1")
  18. flag.Set("deploy_env", "uat")
  19. flag.Set("conf_host", "config.bilibili.co")
  20. flag.Set("conf_path", "/tmp")
  21. flag.Set("region", "sh")
  22. flag.Set("zone", "sh001")
  23. } else {
  24. dir, _ := filepath.Abs("../cmd/push-job-test.toml")
  25. flag.Set("conf", dir)
  26. }
  27. flag.Parse()
  28. if err := conf.Init(); err != nil {
  29. panic(err)
  30. }
  31. d = New(conf.Conf)
  32. os.Exit(m.Run())
  33. }
  34. func Test_Wechat(t *testing.T) {
  35. Convey("test wechat message", t, func() {
  36. err := d.SendWechat("test send wechat message")
  37. So(err, ShouldBeNil)
  38. })
  39. }
  40. func Test_DpDownloadFile(t *testing.T) {
  41. Convey("data platform download file", t, func() {
  42. _, err := d.DpDownloadFile(context.Background(), "https://raw.githubusercontent.com/Bilibili/discovery/master/README.md")
  43. So(err, ShouldBeNil)
  44. })
  45. }
  46. func Test_DpSubmitQuery(t *testing.T) {
  47. Convey("data platform submit query", t, func() {
  48. url, err := d.DpSubmitQuery(context.Background(), "select device_token from basic.dws_push_buvid where log_date='20180707'")
  49. So(err, ShouldNotBeNil)
  50. t.Logf("url(%v)", url)
  51. })
  52. }