dao_test.go 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dao
  2. import (
  3. "flag"
  4. "fmt"
  5. "os"
  6. "testing"
  7. "go-common/app/service/main/history/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.community.history-service")
  15. flag.Set("conf_token", "10f1bb6e589c42e7e1ee2560aff96b81")
  16. flag.Set("tree_id", "56699")
  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. fmt.Println("") // 存在才能pass
  25. flag.Set("conf", "../cmd/history-service-test.toml")
  26. }
  27. flag.Parse()
  28. if err := conf.Init(); err != nil {
  29. panic(err)
  30. }
  31. d = New(conf.Conf)
  32. m.Run()
  33. os.Exit(0)
  34. }
  35. // INSERT INTO `bilibili_history`.`histories`(`mtime`, `ctime`, `mid`, `business_id`, `kid`, `aid`, `sid`, `epid`, `sub_type`, `cid`, `device`, `progress`, `view_at`) VALUES ('2018-08-27 03:03:50', '2018-08-27 03:01:29', 1, 4, 2, 3, 4, 5, 7, 6, 8, 9, 10);