dao_test.go 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package upcrm
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/up/conf"
  8. )
  9. var (
  10. d *Dao
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", "main.archive.mcn-admin")
  15. flag.Set("conf_token", "220af473858ad67f75586b66bece0e6b")
  16. flag.Set("tree_id", "58930")
  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. }
  24. flag.Set("conf", "../../cmd/up-job.toml")
  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 TestGetDueTask(t *testing.T) {
  34. var date, _ = time.Parse("2006-01-02", "2018-11-02")
  35. var res, err = d.GetDueTask(date)
  36. if err != nil {
  37. t.Errorf("err get tasks, err=%v", err)
  38. t.FailNow()
  39. }
  40. for i, v := range res {
  41. t.Logf("[%d]res=%+v", i, v)
  42. }
  43. }