The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/queryhistory/queryhistory_patch_test.go

29 lines
1.0 KiB

package queryhistory
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/web"
)
func TestIntegrationPatchQueryCommentInQueryHistory(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
testScenarioWithQueryInQueryHistory(t, "When user tries to patch comment of query in query history that does not exist, it should fail",
func(t *testing.T, sc scenarioContext) {
resp := sc.service.patchCommentHandler(sc.reqContext)
require.Equal(t, 500, resp.Status())
})
testScenarioWithQueryInQueryHistory(t, "When user tries to patch comment of query in query history that exists, it should succeed",
func(t *testing.T, sc scenarioContext) {
cmd := PatchQueryCommentInQueryHistoryCommand{Comment: "test comment"}
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
sc.reqContext.Req.Body = mockRequestBody(cmd)
resp := sc.service.patchCommentHandler(sc.reqContext)
require.Equal(t, 200, resp.Status())
})
}