mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #12387 from AustinWinstanley/master
Return a 404 when deleting a datasource through the API if it doesn't…
This commit is contained in:
commit
15bbe81fed
@ -103,6 +103,9 @@ func DeleteDataSourceByName(c *m.ReqContext) Response {
|
|||||||
|
|
||||||
getCmd := &m.GetDataSourceByNameQuery{Name: name, OrgId: c.OrgId}
|
getCmd := &m.GetDataSourceByNameQuery{Name: name, OrgId: c.OrgId}
|
||||||
if err := bus.Dispatch(getCmd); err != nil {
|
if err := bus.Dispatch(getCmd); err != nil {
|
||||||
|
if err == m.ErrDataSourceNotFound {
|
||||||
|
return Error(404, "Data source not found", nil)
|
||||||
|
}
|
||||||
return Error(500, "Failed to delete datasource", err)
|
return Error(500, "Failed to delete datasource", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,5 +46,13 @@ func TestDataSourcesProxy(t *testing.T) {
|
|||||||
So(respJSON[3]["name"], ShouldEqual, "ZZZ")
|
So(respJSON[3]["name"], ShouldEqual, "ZZZ")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("Should be able to save a data source", func() {
|
||||||
|
loggedInUserScenario("When calling DELETE on non-existing", "/api/datasources/name/12345", func(sc *scenarioContext) {
|
||||||
|
sc.handlerFunc = DeleteDataSourceByName
|
||||||
|
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{}).exec()
|
||||||
|
So(sc.resp.Code, ShouldEqual, 404)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user