You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2KB

  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "testing"
  6. )
  7. func SetupConfig() {
  8. APIConfig = WechatAPIConfig{
  9. "skdq8vklaurfqemfszuif",
  10. "cmtWK2teRnLOXyO5dw7lJkETv9jCeNAqYyguEu5D8gG",
  11. "wx876e233fde456b7b",
  12. "4a91aa328569b10a9fb97adeb8b0af58",
  13. "/tmp/wechat_hitxy_access_token",
  14. "gh_f09231355c68"}
  15. CRMConfig = EspoCRMAPIConfig{
  16. "https://c.hitxy.org.au/",
  17. "wechat",
  18. "crmwechat.api"}
  19. GlobalPath = PathsConfig{"/tmp", "/tmp"}
  20. }
  21. func AssertEqual(t *testing.T, a interface{}, b interface{}, message string) {
  22. if a == b {
  23. return
  24. }
  25. if len(message) == 0 {
  26. message = fmt.Sprintf("%v != %v", a, b)
  27. }
  28. message = fmt.Sprintf("%s : %s", MyCaller(), message)
  29. t.Fatal(message)
  30. }
  31. func TestDummy(t *testing.T) {
  32. t.Log("Testing common field")
  33. }
  34. // MyCaller returns the caller of the function that called it :)
  35. func MyCaller() string {
  36. // we get the callers as uintptrs - but we just need 1
  37. fpcs := make([]uintptr, 1)
  38. // skip 3 levels to get to the caller of whoever called Caller()
  39. n := runtime.Callers(3, fpcs)
  40. if n == 0 {
  41. return "n/a" // proper error her would be better
  42. }
  43. // get the info of the actual function that's in the pointer
  44. fun := runtime.FuncForPC(fpcs[0] - 1)
  45. if fun == nil {
  46. return "n/a"
  47. }
  48. // return its name
  49. return fun.Name()
  50. }