您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

78 行
1.6KB

  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "os"
  6. "runtime"
  7. "testing"
  8. )
  9. func TestMain(m *testing.M) {
  10. log.Println("global setup for all test cases ... ")
  11. SetupConfig()
  12. code := m.Run()
  13. //Shutdown
  14. log.Println("global shutdown for all test cases ... ")
  15. os.Exit(code)
  16. }
  17. func SetupConfig() {
  18. APIConfig = WechatAPIConfig{
  19. "skdq8vklaurfqemfszuif",
  20. "cmtWK2teRnLOXyO5dw7lJkETv9jCeNAqYyguEu5D8gG",
  21. "wx876e233fde456b7b",
  22. "4a91aa328569b10a9fb97adeb8b0af58",
  23. "/tmp/wechat_hitxy_token",
  24. "gh_f09231355c68"}
  25. CRMConfig = EspoCRMAPIConfig{
  26. "https://c.hitxy.org.au/",
  27. "wechat",
  28. "crmwechat.api",
  29. "/tmp/",
  30. "http://192.168.1.39:65500/crmcache"}
  31. IntraAPIConfig = ConfigIntraAPI{
  32. "cAT/ckkfjajvczxiaufodqdfakpozcczfas341fda.vfasdk/8934125",
  33. }
  34. GlobalPath = PathsConfig{"/tmp", "spa/"}
  35. KFUsers.kfRenewList()
  36. }
  37. func AssertEqual(t *testing.T, a interface{}, b interface{}, message string) {
  38. if a == b {
  39. return
  40. }
  41. if len(message) == 0 {
  42. message = fmt.Sprintf("%v != %v", a, b)
  43. }
  44. message = fmt.Sprintf("%s : %s", MyCaller(), message)
  45. t.Fatal(message)
  46. }
  47. func TestDummy(t *testing.T) {
  48. t.Log("Testing common field")
  49. }
  50. // MyCaller returns the caller of the function that called it :)
  51. func MyCaller() string {
  52. // we get the callers as uintptrs - but we just need 1
  53. fpcs := make([]uintptr, 1)
  54. // skip 3 levels to get to the caller of whoever called Caller()
  55. n := runtime.Callers(3, fpcs)
  56. if n == 0 {
  57. return "n/a" // proper error her would be better
  58. }
  59. // get the info of the actual function that's in the pointer
  60. fun := runtime.FuncForPC(fpcs[0] - 1)
  61. if fun == nil {
  62. return "n/a"
  63. }
  64. // return its name
  65. return fun.Name()
  66. }