Worked on search filter flag IsStarred, and updated frontend with new dashboard list panel

This commit is contained in:
Torkel Ödegaard
2015-02-04 11:35:59 +01:00
parent f0b13153ac
commit 60541a455f
11 changed files with 99 additions and 33 deletions

View File

@@ -8,27 +8,29 @@ import (
m "github.com/torkelo/grafana-pro/pkg/models"
)
func insertTestDashboard(title string, accountId int64, tags ...interface{}) *m.Dashboard {
cmd := m.SaveDashboardCommand{
AccountId: accountId,
Dashboard: map[string]interface{}{
"id": nil,
"title": title,
"tags": tags,
},
}
err := SaveDashboard(&cmd)
So(err, ShouldBeNil)
return cmd.Result
}
func TestDashboardDataAccess(t *testing.T) {
Convey("Testing DB", t, func() {
InitTestDB(t)
Convey("Given saved dashboard", func() {
var savedDash *m.Dashboard
cmd := m.SaveDashboardCommand{
AccountId: 1,
Dashboard: map[string]interface{}{
"id": nil,
"title": "test dash 23",
"tags": []interface{}{"prod", "webapp"},
},
}
err := SaveDashboard(&cmd)
So(err, ShouldBeNil)
savedDash = cmd.Result
savedDash := insertTestDashboard("test dash 23", 1, "prod", "webapp")
Convey("Should return dashboard model", func() {
So(savedDash.Title, ShouldEqual, "test dash 23")
@@ -97,6 +99,28 @@ func TestDashboardDataAccess(t *testing.T) {
So(len(query.Result), ShouldEqual, 2)
})
Convey("Given two dashboards, one is starred dashboard by user 10, other starred by user 1", func() {
starredDash := insertTestDashboard("starred dash", 1)
StarDashboard(&m.StarDashboardCommand{
DashboardId: starredDash.Id,
UserId: 10,
})
StarDashboard(&m.StarDashboardCommand{
DashboardId: savedDash.Id,
UserId: 1,
})
Convey("Should be able to search for starred dashboards", func() {
query := m.SearchDashboardsQuery{AccountId: 1, UserId: 10, IsStarred: true}
err := SearchDashboards(&query)
So(err, ShouldBeNil)
So(len(query.Result), ShouldEqual, 1)
So(query.Result[0].Title, ShouldEqual, "starred dash")
})
})
})
})
}