Prevent spurious error (#14796)
* Simple fix * Suggestions Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b0b9c707a6
Коммит
3c2b1571f4
@@ -798,4 +798,14 @@ func TestDoOutgoingWebhookRequest(t *testing.T) {
|
|||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
require.IsType(t, &url.Error{}, err)
|
require.IsType(t, &url.Error{}, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("without response", func(t *testing.T) {
|
||||||
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
}))
|
||||||
|
defer server.Close()
|
||||||
|
|
||||||
|
resp, err := th.App.doOutgoingWebhookRequest(server.URL, strings.NewReader(""), "application/json")
|
||||||
|
require.Nil(t, err)
|
||||||
|
require.Nil(t, resp)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ func (o *OutgoingWebhookResponse) ToJson() string {
|
|||||||
func OutgoingWebhookResponseFromJson(data io.Reader) (*OutgoingWebhookResponse, error) {
|
func OutgoingWebhookResponseFromJson(data io.Reader) (*OutgoingWebhookResponse, error) {
|
||||||
var o *OutgoingWebhookResponse
|
var o *OutgoingWebhookResponse
|
||||||
err := json.NewDecoder(data).Decode(&o)
|
err := json.NewDecoder(data).Decode(&o)
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return o, err
|
return o, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user