2022-02-23 10:03:04 -06:00
|
|
|
package queryhistory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-01-30 02:21:27 -06:00
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/web"
|
2022-02-23 10:03:04 -06:00
|
|
|
)
|
|
|
|
|
2022-05-24 04:04:03 -05:00
|
|
|
func TestIntegrationStarQueryInQueryHistory(t *testing.T) {
|
2022-06-10 10:46:21 -05:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping integration test")
|
|
|
|
}
|
2022-02-23 10:03:04 -06:00
|
|
|
testScenarioWithQueryInQueryHistory(t, "When users tries to star query in query history that does not exists, it should fail",
|
|
|
|
func(t *testing.T, sc scenarioContext) {
|
|
|
|
resp := sc.service.starHandler(sc.reqContext)
|
|
|
|
require.Equal(t, 500, resp.Status())
|
|
|
|
})
|
|
|
|
|
|
|
|
testScenarioWithQueryInQueryHistory(t, "When users tries to star 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.starHandler(sc.reqContext)
|
|
|
|
require.Equal(t, 200, resp.Status())
|
|
|
|
})
|
|
|
|
|
|
|
|
testScenarioWithQueryInQueryHistory(t, "When users tries to star query that is already starred, it should fail",
|
|
|
|
func(t *testing.T, sc scenarioContext) {
|
|
|
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
|
|
|
sc.service.starHandler(sc.reqContext)
|
|
|
|
resp := sc.service.starHandler(sc.reqContext)
|
|
|
|
require.Equal(t, 500, resp.Status())
|
|
|
|
})
|
|
|
|
}
|