pkg/api: Check errors (#19657)
* pkg/api: Check errors * pkg/api: Remove unused function HashEmail
This commit is contained in:
@@ -152,9 +152,10 @@ func TestDashboardSnapshotApiEndpoint(t *testing.T) {
|
||||
mockSnapshotResult.UserId = TestUserID
|
||||
|
||||
Convey("Should gracefully delete local snapshot when remote snapshot has already been removed", func() {
|
||||
var writeErr error
|
||||
loggedInUserScenarioWithRole("When calling DELETE on", "DELETE", "/api/snapshots/12345", "/api/snapshots/:key", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
||||
ts := setupRemoteServer(func(rw http.ResponseWriter, req *http.Request) {
|
||||
rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
||||
_, writeErr = rw.Write([]byte(`{"message":"Failed to get dashboard snapshot"}`))
|
||||
rw.WriteHeader(500)
|
||||
})
|
||||
|
||||
@@ -162,21 +163,24 @@ func TestDashboardSnapshotApiEndpoint(t *testing.T) {
|
||||
sc.handlerFunc = DeleteDashboardSnapshot
|
||||
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{"key": "12345"}).exec()
|
||||
|
||||
So(writeErr, ShouldBeNil)
|
||||
So(sc.resp.Code, ShouldEqual, 200)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Should fail to delete local snapshot when an unexpected 500 error occurs", func() {
|
||||
loggedInUserScenarioWithRole("When calling DELETE on", "DELETE", "/api/snapshots/12345", "/api/snapshots/:key", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
||||
var writeErr error
|
||||
ts := setupRemoteServer(func(rw http.ResponseWriter, req *http.Request) {
|
||||
rw.WriteHeader(500)
|
||||
rw.Write([]byte(`{"message":"Unexpected"}`))
|
||||
_, writeErr = rw.Write([]byte(`{"message":"Unexpected"}`))
|
||||
})
|
||||
|
||||
mockSnapshotResult.ExternalDeleteUrl = ts.URL
|
||||
sc.handlerFunc = DeleteDashboardSnapshot
|
||||
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{"key": "12345"}).exec()
|
||||
|
||||
So(writeErr, ShouldBeNil)
|
||||
So(sc.resp.Code, ShouldEqual, 500)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user