test: more debug info for errors
package api_test
import (
+ "fmt"
"log"
"os"
"reflect"
@@ -26,6 +27,20 @@ func noError(t *testing.T, err error) bool {
case errors.Captcha:
t.Skip("Captcha needed")
}
+ if err != nil {
+ ctx := errors.GetErrorContext(err)
+ if ctx.Code != 0 {
+ var s string
+ s += fmt.Sprintf("code: %d\n", ctx.Code)
+ s += fmt.Sprintf("text: %s\n", ctx.Text)
+ s += fmt.Sprintf("message: %s\n", ctx.Message)
+ s += "params:\n"
+ for _, param := range ctx.RequestParams {
+ s += fmt.Sprintf("\t%s: %s\n", param.Key, param.Value)
+ }
+ t.Log(s)
+ }
+ }
return assert.NoError(t, err)
}
