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 {
|
||||
return err
|
||||
}
|
||||
if err := response.Body.Close(); err != nil {
|
||||
plog.Warn("Failed closing response body", "err", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := response.Body.Close(); err != nil {
|
||||
plog.Warn("Failed to close response body", "err", err)
|
||||
}
|
||||
}()
|
||||
|
||||
if response.StatusCode == 200 {
|
||||
return nil
|
||||
|
@ -171,16 +171,16 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
|
||||
|
||||
t.Run("When deleting an external snapshot", func(t *testing.T) {
|
||||
aclMockResp = []*models.DashboardAclInfoDTO{}
|
||||
var writeErr error
|
||||
loggedInUserScenarioWithRole(t,
|
||||
"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) {
|
||||
mockSnapshotResult := setUpSnapshotTest(t)
|
||||
mockSnapshotResult.UserId = testUserID
|
||||
|
||||
var writeErr error
|
||||
ts := setupRemoteServer(func(rw http.ResponseWriter, req *http.Request) {
|
||||
_, writeErr = rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
||||
rw.WriteHeader(500)
|
||||
_, writeErr = rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
||||
})
|
||||
|
||||
mockSnapshotResult.ExternalDeleteUrl = ts.URL
|
||||
|
Loading…
Reference in New Issue
Block a user