mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix http: superfluous response.WriteHeader error when deleting an external snapshot (#36780)
This commit is contained in:
parent
fdad8558ee
commit
b164c90e91
@ -185,9 +185,12 @@ func deleteExternalDashboardSnapshot(externalUrl string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
if err := response.Body.Close(); err != nil {
|
if err := response.Body.Close(); err != nil {
|
||||||
plog.Warn("Failed closing response body", "err", err)
|
plog.Warn("Failed to close response body", "err", err)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if response.StatusCode == 200 {
|
if response.StatusCode == 200 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -171,16 +171,16 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("When deleting an external snapshot", func(t *testing.T) {
|
t.Run("When deleting an external snapshot", func(t *testing.T) {
|
||||||
aclMockResp = []*models.DashboardAclInfoDTO{}
|
aclMockResp = []*models.DashboardAclInfoDTO{}
|
||||||
var writeErr error
|
|
||||||
loggedInUserScenarioWithRole(t,
|
loggedInUserScenarioWithRole(t,
|
||||||
"Should gracefully delete local snapshot when remote snapshot has already been removed when calling DELETE on",
|
"Should gracefully delete local snapshot when remote snapshot has already been removed when calling DELETE on",
|
||||||
"DELETE", "/api/snapshots/12345", "/api/snapshots/:key", models.ROLE_EDITOR, func(sc *scenarioContext) {
|
"DELETE", "/api/snapshots/12345", "/api/snapshots/:key", models.ROLE_EDITOR, func(sc *scenarioContext) {
|
||||||
mockSnapshotResult := setUpSnapshotTest(t)
|
mockSnapshotResult := setUpSnapshotTest(t)
|
||||||
mockSnapshotResult.UserId = testUserID
|
mockSnapshotResult.UserId = testUserID
|
||||||
|
|
||||||
|
var writeErr error
|
||||||
ts := setupRemoteServer(func(rw http.ResponseWriter, req *http.Request) {
|
ts := setupRemoteServer(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
_, writeErr = rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
|
||||||
rw.WriteHeader(500)
|
rw.WriteHeader(500)
|
||||||
|
_, writeErr = rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
||||||
})
|
})
|
||||||
|
|
||||||
mockSnapshotResult.ExternalDeleteUrl = ts.URL
|
mockSnapshotResult.ExternalDeleteUrl = ts.URL
|
||||||
|
Loading…
Reference in New Issue
Block a user