No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

54 líneas
1.1KB

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