fix: Allow custom Git OAuth URLs (#4758)

Fixes an issue reported in Discord where custom endpoints
weren't working.
This commit is contained in:
Kyle Carberry
2022-10-27 10:38:05 -07:00
committed by GitHub
parent 3e15ee3ba0
commit b34a67e6cb
8 changed files with 63 additions and 13 deletions
+5 -5
View File
@@ -34,7 +34,7 @@ func Test_readBodyAsError(t *testing.T) {
longResponse += "a"
}
unexpectedJSON := marshalJSON(map[string]any{
unexpectedJSON := marshal(map[string]any{
"hello": "world",
"foo": "bar",
})
@@ -49,7 +49,7 @@ func Test_readBodyAsError(t *testing.T) {
{
name: "JSONWithRequest",
req: httptest.NewRequest(http.MethodGet, exampleURL, nil),
res: newResponse(http.StatusNotFound, jsonCT, marshalJSON(simpleResponse)),
res: newResponse(http.StatusNotFound, jsonCT, marshal(simpleResponse)),
assert: func(t *testing.T, err error) {
sdkErr := assertSDKError(t, err)
@@ -72,7 +72,7 @@ func Test_readBodyAsError(t *testing.T) {
{
name: "JSONWithoutRequest",
req: nil,
res: newResponse(http.StatusNotFound, jsonCT, marshalJSON(simpleResponse)),
res: newResponse(http.StatusNotFound, jsonCT, marshal(simpleResponse)),
assert: func(t *testing.T, err error) {
sdkErr := assertSDKError(t, err)
@@ -86,7 +86,7 @@ func Test_readBodyAsError(t *testing.T) {
{
name: "UnauthorizedHelper",
req: nil,
res: newResponse(http.StatusUnauthorized, jsonCT, marshalJSON(simpleResponse)),
res: newResponse(http.StatusUnauthorized, jsonCT, marshal(simpleResponse)),
assert: func(t *testing.T, err error) {
sdkErr := assertSDKError(t, err)
@@ -190,7 +190,7 @@ func newResponse(status int, contentType string, body interface{}) *http.Respons
}
}
func marshalJSON(res any) string {
func marshal(res any) string {
b, err := json.Marshal(res)
if err != nil {
panic(err)