dao_test.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dao
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/aegis/conf"
  8. "go-common/app/job/main/aegis/model"
  9. )
  10. var (
  11. d *Dao
  12. task1 = &model.Task{ID: 1, BusinessID: 1, FlowID: 1, UID: 1, Weight: 3, Ctime: model.IntTime(time.Now().Unix())}
  13. task2 = &model.Task{ID: 2, BusinessID: 1, FlowID: 1, UID: 1, Weight: 2, Ctime: model.IntTime(time.Now().Unix())}
  14. task3 = &model.Task{ID: 3, BusinessID: 1, FlowID: 1, UID: 1, Weight: 1, Ctime: model.IntTime(time.Now().Unix())}
  15. )
  16. func TestMain(m *testing.M) {
  17. if os.Getenv("DEPLOY_ENV") != "" {
  18. flag.Set("app_id", "main.archive.aegis-job")
  19. flag.Set("conf_token", "aed3cc21ca345ffc284c6036da32352b")
  20. flag.Set("tree_id", "61819")
  21. flag.Set("conf_version", "1")
  22. flag.Set("deploy_env", "uat")
  23. flag.Set("conf_host", "config.bilibili.co")
  24. flag.Set("conf_path", "/tmp")
  25. flag.Set("region", "sh")
  26. flag.Set("zone", "sh001")
  27. } else {
  28. flag.Set("conf", "../cmd/aegis-job.toml")
  29. }
  30. flag.Parse()
  31. if err := conf.Init(); err != nil {
  32. panic(err)
  33. }
  34. d = New(conf.Conf)
  35. os.Exit(m.Run())
  36. }