Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

62 lines
1.3KB

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