mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
636a45f065
* Query history: Patch comment * Update docs/sources/http_api/query_history.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/http_api/query_history.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Remove redundant check * Use WithTransactionalDbSession to update comment * Fix status code in test Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
24 lines
811 B
Go
24 lines
811 B
Go
package queryhistory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/web"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDeleteQueryFromQueryHistory(t *testing.T) {
|
|
testScenarioWithQueryInQueryHistory(t, "When users tries to delete query in query history that does not exist, it should fail",
|
|
func(t *testing.T, sc scenarioContext) {
|
|
resp := sc.service.deleteHandler(sc.reqContext)
|
|
require.Equal(t, 500, resp.Status())
|
|
})
|
|
|
|
testScenarioWithQueryInQueryHistory(t, "When users tries to delete query in query history that exists, it should succeed",
|
|
func(t *testing.T, sc scenarioContext) {
|
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
|
resp := sc.service.deleteHandler(sc.reqContext)
|
|
require.Equal(t, 200, resp.Status())
|
|
})
|
|
}
|