Chore: Remove result field from dashboards (#65249)

remove result field from dashboards
This commit is contained in:
Serge Zaitsev 2023-03-30 07:29:52 +02:00 committed by GitHub
parent 959349d191
commit 4b551ae532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 125 deletions

View File

@ -6,6 +6,7 @@ import (
alertmodels "github.com/grafana/grafana/pkg/services/alerting/models"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/quota"
"github.com/grafana/grafana/pkg/services/search/model"
)
// DashboardService is a service for operating on dashboards.
@ -25,7 +26,7 @@ type DashboardService interface {
ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*Dashboard, error)
MakeUserAdmin(ctx context.Context, orgID int64, userID, dashboardID int64, setViewAndEditPermissions bool) error
SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*Dashboard, error)
SearchDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) error
SearchDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) (model.HitList, error)
UpdateDashboardACL(ctx context.Context, uid int64, items []*DashboardACL) error
DeleteACLByUser(ctx context.Context, userID int64) error
CountDashboardsInFolder(ctx context.Context, query *CountDashboardsInFolderQuery) (int64, error)

View File

@ -7,6 +7,8 @@ import (
folder "github.com/grafana/grafana/pkg/services/folder"
mock "github.com/stretchr/testify/mock"
model "github.com/grafana/grafana/pkg/services/search/model"
)
// FakeDashboardService is an autogenerated mock type for the DashboardService type
@ -327,17 +329,26 @@ func (_m *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDash
}
// SearchDashboards provides a mock function with given fields: ctx, query
func (_m *FakeDashboardService) SearchDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) error {
func (_m *FakeDashboardService) SearchDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) (model.HitList, error) {
ret := _m.Called(ctx, query)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *FindPersistedDashboardsQuery) error); ok {
var r0 model.HitList
if rf, ok := ret.Get(0).(func(context.Context, *FindPersistedDashboardsQuery) model.HitList); ok {
r0 = rf(ctx, query)
} else {
r0 = ret.Error(0)
if ret.Get(0) != nil {
r0 = ret.Get(0).(model.HitList)
}
}
return r0
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *FindPersistedDashboardsQuery) error); ok {
r1 = rf(ctx, query)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateDashboardACL provides a mock function with given fields: ctx, uid, items

View File

@ -55,11 +55,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{flder.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, flder.ID)
require.Equal(t, query.Result[1].ID, dashInRoot.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, flder.ID)
require.Equal(t, hits[1].ID, dashInRoot.ID)
})
})
@ -78,11 +78,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
SignedInUser: &user.SignedInUser{UserID: currentUser.ID, OrgID: 1, OrgRole: org.RoleViewer},
OrgId: 1, DashboardIds: []int64{flder.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.Equal(t, query.Result[0].ID, dashInRoot.ID)
require.Equal(t, len(hits), 1)
require.Equal(t, hits[0].ID, dashInRoot.ID)
})
t.Run("when the user is given permission", func(t *testing.T) {
@ -97,11 +97,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{flder.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, flder.ID)
require.Equal(t, query.Result[1].ID, dashInRoot.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, flder.ID)
require.Equal(t, hits[1].ID, dashInRoot.ID)
})
})
@ -116,11 +116,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{flder.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, flder.ID)
require.Equal(t, query.Result[1].ID, dashInRoot.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, flder.ID)
require.Equal(t, hits[1].ID, dashInRoot.ID)
})
})
})
@ -138,10 +138,10 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
SignedInUser: &user.SignedInUser{UserID: currentUser.ID, OrgID: 1, OrgRole: org.RoleViewer}, OrgId: 1, DashboardIds: []int64{flder.ID, childDash.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.Equal(t, query.Result[0].ID, dashInRoot.ID)
require.Equal(t, len(hits), 1)
require.Equal(t, hits[0].ID, dashInRoot.ID)
})
t.Run("when the user is given permission to child", func(t *testing.T) {
@ -152,11 +152,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("should be able to search for child dashboard but not folder", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{SignedInUser: &user.SignedInUser{UserID: currentUser.ID, OrgID: 1, OrgRole: org.RoleViewer}, OrgId: 1, DashboardIds: []int64{flder.ID, childDash.ID, dashInRoot.ID}}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, childDash.ID)
require.Equal(t, query.Result[1].ID, dashInRoot.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, childDash.ID)
require.Equal(t, hits[1].ID, dashInRoot.ID)
})
})
@ -171,12 +171,12 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{flder.ID, dashInRoot.ID, childDash.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 3)
require.Equal(t, query.Result[0].ID, flder.ID)
require.Equal(t, query.Result[1].ID, childDash.ID)
require.Equal(t, query.Result[2].ID, dashInRoot.ID)
require.Equal(t, len(hits), 3)
require.Equal(t, hits[0].ID, flder.ID)
require.Equal(t, hits[1].ID, childDash.ID)
require.Equal(t, hits[2].ID, dashInRoot.ID)
})
})
})
@ -212,13 +212,13 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
},
OrgId: 1,
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 4)
require.Equal(t, query.Result[0].ID, folder1.ID)
require.Equal(t, query.Result[1].ID, folder2.ID)
require.Equal(t, query.Result[2].ID, childDash1.ID)
require.Equal(t, query.Result[3].ID, dashInRoot.ID)
require.Equal(t, len(hits), 4)
require.Equal(t, hits[0].ID, folder1.ID)
require.Equal(t, hits[1].ID, folder2.ID)
require.Equal(t, hits[2].ID, childDash1.ID)
require.Equal(t, hits[3].ID, dashInRoot.ID)
})
})
@ -238,10 +238,10 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{folder1.ID, childDash1.ID, childDash2.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.Equal(t, query.Result[0].ID, dashInRoot.ID)
require.Equal(t, len(hits), 1)
require.Equal(t, hits[0].ID, dashInRoot.ID)
})
})
t.Run("and a dashboard is moved from folder with acl to the folder without an acl", func(t *testing.T) {
@ -254,13 +254,13 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{folder2.ID, childDash1.ID, childDash2.ID, dashInRoot.ID},
}
err := testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 4)
require.Equal(t, query.Result[0].ID, folder2.ID)
require.Equal(t, query.Result[1].ID, childDash1.ID)
require.Equal(t, query.Result[2].ID, childDash2.ID)
require.Equal(t, query.Result[3].ID, dashInRoot.ID)
require.Equal(t, len(hits), 4)
require.Equal(t, hits[0].ID, folder2.ID)
require.Equal(t, hits[1].ID, childDash1.ID)
require.Equal(t, hits[2].ID, childDash2.ID)
require.Equal(t, hits[3].ID, dashInRoot.ID)
})
})
@ -278,13 +278,13 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
OrgId: 1,
DashboardIds: []int64{folder2.ID, childDash1.ID, childDash2.ID, dashInRoot.ID},
}
err = testSearchDashboards(dashboardStore, query)
hits, err := testSearchDashboards(dashboardStore, query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 4)
require.Equal(t, query.Result[0].ID, folder2.ID)
require.Equal(t, query.Result[1].ID, childDash1.ID)
require.Equal(t, query.Result[2].ID, childDash2.ID)
require.Equal(t, query.Result[3].ID, dashInRoot.ID)
require.Equal(t, len(hits), 4)
require.Equal(t, hits[0].ID, folder2.ID)
require.Equal(t, hits[1].ID, childDash1.ID)
require.Equal(t, hits[2].ID, childDash2.ID)
require.Equal(t, hits[3].ID, dashInRoot.ID)
})
})
})
@ -319,12 +319,12 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
Type: "dash-folder",
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, folder1.ID)
require.Equal(t, query.Result[1].ID, folder2.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, folder1.ID)
require.Equal(t, hits[1].ID, folder2.ID)
})
t.Run("should have edit permission in folders", func(t *testing.T) {
@ -354,12 +354,12 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
}
t.Run("Should have write access to all dashboard folders with default ACL", func(t *testing.T) {
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, query.Result[0].ID, folder1.ID)
require.Equal(t, query.Result[1].ID, folder2.ID)
require.Equal(t, len(hits), 2)
require.Equal(t, hits[0].ID, folder1.ID)
require.Equal(t, hits[1].ID, folder2.ID)
})
t.Run("Should have write access to one dashboard folder if default role changed to view for one folder", func(t *testing.T) {
@ -368,11 +368,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
})
require.NoError(t, err)
err = testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.Equal(t, query.Result[0].ID, folder2.ID)
require.Equal(t, len(hits), 1)
require.Equal(t, hits[0].ID, folder2.ID)
})
t.Run("should have edit permission in folders", func(t *testing.T) {
@ -402,10 +402,10 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
}
t.Run("Should have no write access to any dashboard folders with default ACL", func(t *testing.T) {
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 0)
require.Equal(t, len(hits), 0)
})
t.Run("Should be able to get one dashboard folder if default role changed to edit for one folder", func(t *testing.T) {
@ -414,11 +414,11 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
})
require.NoError(t, err)
err = testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.Equal(t, query.Result[0].ID, folder1.ID)
require.Equal(t, len(hits), 1)
require.Equal(t, hits[0].ID, folder1.ID)
})
t.Run("should not have edit permission in folders", func(t *testing.T) {

View File

@ -346,11 +346,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
hit := query.Result[0]
require.Equal(t, len(hits), 1)
hit := hits[0]
require.Equal(t, hit.Type, model.DashHitFolder)
require.Equal(t, hit.URL, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.UID, savedFolder.Slug))
require.Equal(t, hit.FolderTitle, "")
@ -370,11 +370,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.EqualValues(t, query.Result[0].Title, "1 test dash folder")
require.Equal(t, len(hits), 1)
require.EqualValues(t, hits[0].Title, "1 test dash folder")
})
t.Run("Should be able to find results beyond limit using paging", func(t *testing.T) {
@ -395,11 +395,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
require.EqualValues(t, query.Result[0].Title, "test dash 23")
require.Equal(t, len(hits), 1)
require.EqualValues(t, hits[0].Title, "test dash 23")
})
t.Run("Should be able to filter by tag and type", func(t *testing.T) {
@ -417,11 +417,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 3)
require.Equal(t, query.Result[0].Title, "test dash 23")
require.Equal(t, len(hits), 3)
require.Equal(t, hits[0].Title, "test dash 23")
})
t.Run("Should be able to find a dashboard folder's children", func(t *testing.T) {
@ -438,11 +438,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
hit := query.Result[0]
require.Equal(t, len(hits), 2)
hit := hits[0]
require.Equal(t, hit.ID, savedDash.ID)
require.Equal(t, hit.URL, fmt.Sprintf("/d/%s/%s", savedDash.UID, savedDash.Slug))
require.Equal(t, hit.FolderID, savedFolder.ID)
@ -464,15 +464,15 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
},
}
err := testSearchDashboards(dashboardStore, &query)
hits, err := testSearchDashboards(dashboardStore, &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 2)
require.Equal(t, len(hits), 2)
hit := query.Result[0]
hit := hits[0]
require.Equal(t, len(hit.Tags), 2)
hit2 := query.Result[1]
hit2 := hits[1]
require.Equal(t, len(hit2.Tags), 1)
})
@ -751,17 +751,17 @@ func updateDashboardACL(t *testing.T, dashboardStore dashboards.Store, dashboard
// testSearchDashboards is a (near) copy of the dashboard service
// SearchDashboards, which is a wrapper around FindDashboards.
func testSearchDashboards(d dashboards.Store, query *dashboards.FindPersistedDashboardsQuery) error {
func testSearchDashboards(d dashboards.Store, query *dashboards.FindPersistedDashboardsQuery) (model.HitList, error) {
res, err := d.FindDashboards(context.Background(), query)
if err != nil {
return err
return nil, err
}
makeQueryResult(query, res)
return nil
hits := makeQueryResult(query, res)
return hits, nil
}
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) {
query.Result = make([]*model.Hit, 0)
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) model.HitList {
hitList := make([]*model.Hit, 0)
hits := make(map[int64]*model.Hit)
for _, item := range res {
@ -794,11 +794,12 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb
hit.SortMetaName = query.Sort.MetaName
}
query.Result = append(query.Result, hit)
hitList = append(hitList, hit)
hits[item.ID] = hit
}
if len(item.Term) > 0 {
hit.Tags = append(hit.Tags, item.Term)
}
}
return hitList
}

View File

@ -430,6 +430,4 @@ type FindPersistedDashboardsQuery struct {
Sort model.SortOption
Filters []interface{}
Result model.HitList
}

View File

@ -547,15 +547,15 @@ func (dr *DashboardServiceImpl) FindDashboards(ctx context.Context, query *dashb
return dr.dashboardStore.FindDashboards(ctx, query)
}
func (dr *DashboardServiceImpl) SearchDashboards(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) error {
func (dr *DashboardServiceImpl) SearchDashboards(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) (model.HitList, error) {
res, err := dr.FindDashboards(ctx, query)
if err != nil {
return err
return nil, err
}
makeQueryResult(query, res)
hits := makeQueryResult(query, res)
return nil
return hits, nil
}
func getHitType(item dashboards.DashboardSearchProjection) model.HitType {
@ -569,8 +569,8 @@ func getHitType(item dashboards.DashboardSearchProjection) model.HitType {
return hitType
}
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) {
query.Result = make([]*model.Hit, 0)
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) model.HitList {
hitList := make([]*model.Hit, 0)
hits := make(map[int64]*model.Hit)
for _, item := range res {
@ -598,13 +598,14 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb
hit.SortMetaName = query.Sort.MetaName
}
query.Result = append(query.Result, hit)
hitList = append(hitList, hit)
hits[item.ID] = hit
}
if len(item.Term) > 0 {
hit.Tags = append(hit.Tags, item.Term)
}
}
return hitList
}
func (dr *DashboardServiceImpl) GetDashboardACLInfoList(ctx context.Context, query *dashboards.GetDashboardACLInfoListQuery) ([]*dashboards.DashboardACLInfoDTO, error) {

View File

@ -96,11 +96,11 @@ func (s *SearchService) SearchHandler(ctx context.Context, query *Query) error {
dashboardQuery.Sort = sortOpt
}
if err := s.dashboardService.SearchDashboards(ctx, &dashboardQuery); err != nil {
hits, err := s.dashboardService.SearchDashboards(ctx, &dashboardQuery)
if err != nil {
return err
}
hits := dashboardQuery.Result
if query.Sort == "" {
hits = sortedHits(hits)
}

View File

@ -22,16 +22,13 @@ func TestSearch_SortedResults(t *testing.T) {
db := dbtest.NewFakeDB()
us := usertest.NewUserServiceFake()
ds := dashboards.NewFakeDashboardService(t)
ds.On("SearchDashboards", mock.Anything, mock.AnythingOfType("*dashboards.FindPersistedDashboardsQuery")).Run(func(args mock.Arguments) {
q := args.Get(1).(*dashboards.FindPersistedDashboardsQuery)
q.Result = model.HitList{
&model.Hit{ID: 16, Title: "CCAA", Type: "dash-db", Tags: []string{"BB", "AA"}},
&model.Hit{ID: 10, Title: "AABB", Type: "dash-db", Tags: []string{"CC", "AA"}},
&model.Hit{ID: 15, Title: "BBAA", Type: "dash-db", Tags: []string{"EE", "AA", "BB"}},
&model.Hit{ID: 25, Title: "bbAAa", Type: "dash-db", Tags: []string{"EE", "AA", "BB"}},
&model.Hit{ID: 17, Title: "FOLDER", Type: "dash-folder"},
}
}).Return(nil)
ds.On("SearchDashboards", mock.Anything, mock.AnythingOfType("*dashboards.FindPersistedDashboardsQuery")).Return(model.HitList{
&model.Hit{ID: 16, Title: "CCAA", Type: "dash-db", Tags: []string{"BB", "AA"}},
&model.Hit{ID: 10, Title: "AABB", Type: "dash-db", Tags: []string{"CC", "AA"}},
&model.Hit{ID: 15, Title: "BBAA", Type: "dash-db", Tags: []string{"EE", "AA", "BB"}},
&model.Hit{ID: 25, Title: "bbAAa", Type: "dash-db", Tags: []string{"EE", "AA", "BB"}},
&model.Hit{ID: 17, Title: "FOLDER", Type: "dash-folder"},
}, nil)
us.ExpectedSignedInUser = &user.SignedInUser{IsGrafanaAdmin: true}
ss.ExpectedUserStars = &star.GetUserStarsResult{UserStars: map[int64]bool{10: true, 12: true}}
svc := &SearchService{
@ -68,14 +65,11 @@ func TestSearch_StarredResults(t *testing.T) {
db := dbtest.NewFakeDB()
us := usertest.NewUserServiceFake()
ds := dashboards.NewFakeDashboardService(t)
ds.On("SearchDashboards", mock.Anything, mock.AnythingOfType("*dashboards.FindPersistedDashboardsQuery")).Run(func(args mock.Arguments) {
q := args.Get(1).(*dashboards.FindPersistedDashboardsQuery)
q.Result = model.HitList{
&model.Hit{ID: 1, Title: "A", Type: "dash-db"},
&model.Hit{ID: 2, Title: "B", Type: "dash-db"},
&model.Hit{ID: 3, Title: "C", Type: "dash-db"},
}
}).Return(nil)
ds.On("SearchDashboards", mock.Anything, mock.AnythingOfType("*dashboards.FindPersistedDashboardsQuery")).Return(model.HitList{
&model.Hit{ID: 1, Title: "A", Type: "dash-db"},
&model.Hit{ID: 2, Title: "B", Type: "dash-db"},
&model.Hit{ID: 3, Title: "C", Type: "dash-db"},
}, nil)
us.ExpectedSignedInUser = &user.SignedInUser{}
ss.ExpectedUserStars = &star.GetUserStarsResult{UserStars: map[int64]bool{1: true, 3: true, 4: true}}
svc := &SearchService{