mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix: fixed dashboard api tests
This commit is contained in:
parent
de91d68402
commit
89db9cc976
@ -14,10 +14,23 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/middleware"
|
"github.com/grafana/grafana/pkg/middleware"
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||||
|
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type fakeDashboardRepo struct {
|
||||||
|
inserted []*dashboards.SaveDashboardItem
|
||||||
|
getDashboard []*m.Dashboard
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *fakeDashboardRepo) SaveDashboard(json *dashboards.SaveDashboardItem) (*m.Dashboard, error) {
|
||||||
|
repo.inserted = append(repo.inserted, json)
|
||||||
|
return json.Dashboard, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var fakeRepo *fakeDashboardRepo
|
||||||
|
|
||||||
func TestDashboardApiEndpoint(t *testing.T) {
|
func TestDashboardApiEndpoint(t *testing.T) {
|
||||||
Convey("Given a dashboard with a parent folder which does not have an acl", t, func() {
|
Convey("Given a dashboard with a parent folder which does not have an acl", t, func() {
|
||||||
fakeDash := m.NewDashboard("Child dash")
|
fakeDash := m.NewDashboard("Child dash")
|
||||||
@ -500,6 +513,9 @@ func postDashboardScenario(desc string, url string, routePattern string, role m.
|
|||||||
return PostDashboard(c, cmd)
|
return PostDashboard(c, cmd)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fakeRepo = &fakeDashboardRepo{}
|
||||||
|
dashboards.SetRepository(fakeRepo)
|
||||||
|
|
||||||
sc.m.Post(routePattern, sc.defaultHandler)
|
sc.m.Post(routePattern, sc.defaultHandler)
|
||||||
|
|
||||||
fn(sc)
|
fn(sc)
|
||||||
|
Loading…
Reference in New Issue
Block a user