remove bus from search and avoid import cycle (#46789)
* fix the import cicle * fix some unittest * fix removal bus from search
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/search"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@@ -211,7 +210,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
err := sqlStore.DeleteDashboard(context.Background(), deleteCmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
OrgId: 1,
|
||||
FolderIds: []int64{savedFolder.Id},
|
||||
SignedInUser: &models.SignedInUser{},
|
||||
@@ -278,7 +277,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to search for dashboard folder", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
Title: "1 test dash folder",
|
||||
OrgId: 1,
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, OrgRole: models.ROLE_EDITOR},
|
||||
@@ -289,14 +288,14 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
hit := query.Result[0]
|
||||
require.Equal(t, hit.Type, search.DashHitFolder)
|
||||
require.Equal(t, hit.Type, models.DashHitFolder)
|
||||
require.Equal(t, hit.URL, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
|
||||
require.Equal(t, hit.FolderTitle, "")
|
||||
})
|
||||
|
||||
t.Run("Should be able to limit search", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
OrgId: 1,
|
||||
Limit: 1,
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, OrgRole: models.ROLE_EDITOR},
|
||||
@@ -311,7 +310,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to search beyond limit using paging", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
OrgId: 1,
|
||||
Limit: 1,
|
||||
Page: 2,
|
||||
@@ -327,7 +326,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to filter by tag and type", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
OrgId: 1,
|
||||
Type: "dash-db",
|
||||
Tags: []string{"prod"},
|
||||
@@ -343,7 +342,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to search for a dashboard folder's children", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
OrgId: 1,
|
||||
FolderIds: []int64{savedFolder.Id},
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, OrgRole: models.ROLE_EDITOR},
|
||||
@@ -364,7 +363,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to search for dashboard by dashboard ids", func(t *testing.T) {
|
||||
setup()
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
DashboardIds: []int64{savedDash.Id, savedDash2.Id},
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
@@ -396,7 +395,7 @@ func TestDashboardDataAccess(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
query := search.FindPersistedDashboardsQuery{
|
||||
query := models.FindPersistedDashboardsQuery{
|
||||
SignedInUser: &models.SignedInUser{UserId: 10, OrgId: 1, OrgRole: models.ROLE_EDITOR},
|
||||
IsStarred: true,
|
||||
}
|
||||
@@ -435,7 +434,7 @@ func TestDashboard_SortingOptions(t *testing.T) {
|
||||
dashA := insertTestDashboard(t, dashboardStore, "Alfa", 1, 0, false)
|
||||
assert.NotZero(t, dashA.Id)
|
||||
assert.Less(t, dashB.Id, dashA.Id)
|
||||
qNoSort := &search.FindPersistedDashboardsQuery{
|
||||
qNoSort := &models.FindPersistedDashboardsQuery{
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, UserId: 1, OrgRole: models.ROLE_ADMIN},
|
||||
}
|
||||
dashboards, err := sqlStore.FindDashboards(context.Background(), qNoSort)
|
||||
@@ -444,10 +443,10 @@ func TestDashboard_SortingOptions(t *testing.T) {
|
||||
assert.Equal(t, dashA.Id, dashboards[0].ID)
|
||||
assert.Equal(t, dashB.Id, dashboards[1].ID)
|
||||
|
||||
qSort := &search.FindPersistedDashboardsQuery{
|
||||
qSort := &models.FindPersistedDashboardsQuery{
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, UserId: 1, OrgRole: models.ROLE_ADMIN},
|
||||
Sort: search.SortOption{
|
||||
Filter: []search.SortOptionFilter{
|
||||
Sort: models.SortOption{
|
||||
Filter: []models.SortOptionFilter{
|
||||
searchstore.TitleSorter{Descending: true},
|
||||
},
|
||||
},
|
||||
@@ -465,14 +464,14 @@ func TestDashboard_Filter(t *testing.T) {
|
||||
dashboardStore := ProvideDashboardStore(sqlStore)
|
||||
insertTestDashboard(t, dashboardStore, "Alfa", 1, 0, false)
|
||||
dashB := insertTestDashboard(t, dashboardStore, "Beta", 1, 0, false)
|
||||
qNoFilter := &search.FindPersistedDashboardsQuery{
|
||||
qNoFilter := &models.FindPersistedDashboardsQuery{
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, UserId: 1, OrgRole: models.ROLE_ADMIN},
|
||||
}
|
||||
dashboards, err := sqlStore.FindDashboards(context.Background(), qNoFilter)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, dashboards, 2)
|
||||
|
||||
qFilter := &search.FindPersistedDashboardsQuery{
|
||||
qFilter := &models.FindPersistedDashboardsQuery{
|
||||
SignedInUser: &models.SignedInUser{OrgId: 1, UserId: 1, OrgRole: models.ROLE_ADMIN},
|
||||
Filters: []interface{}{
|
||||
searchstore.TitleFilter{
|
||||
|
||||
Reference in New Issue
Block a user