mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] tidy up media manager, add calling func to errors, build-script improvements (#1835)
* media manager tidy-up: de-interface and remove unused PostDataFunc Signed-off-by: kim <grufwub@gmail.com> * remove last traces of media.Manager being an interface Signed-off-by: kim <grufwub@gmail.com> * update error to provide caller, allow tuneable via build tags Signed-off-by: kim <grufwub@gmail.com> * remove kim-specific build script changes Signed-off-by: kim <grufwub@gmail.com> * fix merge conflicts Signed-off-by: kim <grufwub@gmail.com> * update build-script to support externally setting build variables Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
)
|
||||
|
||||
func TestResponseError(t *testing.T) {
|
||||
@@ -53,13 +54,19 @@ func testResponseError(t *testing.T, rsp http.Response) {
|
||||
body = string(b[:trunc])
|
||||
}
|
||||
expect := fmt.Sprintf(
|
||||
"%s request to %s failed: status=\"%s\" body=\"%s\"",
|
||||
"%s%s request to %s failed: status=\"%s\" body=\"%s\"",
|
||||
func() string {
|
||||
if gtserror.Caller {
|
||||
return strings.Split(log.Caller(3), ".")[1] + ": "
|
||||
}
|
||||
return ""
|
||||
}(),
|
||||
rsp.Request.Method,
|
||||
rsp.Request.URL.String(),
|
||||
rsp.Status,
|
||||
body,
|
||||
)
|
||||
err := gtserror.NewResponseError(&rsp)
|
||||
err := gtserror.NewFromResponse(&rsp)
|
||||
if str := err.Error(); str != expect {
|
||||
t.Errorf("unexpected error string: recv=%q expct=%q", str, expect)
|
||||
}
|
||||
|
Reference in New Issue
Block a user