2018-05-31 14:44:23 +00:00
|
|
|
package bolt_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/influxdata/platform"
|
|
|
|
platformtesting "github.com/influxdata/platform/testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initDashboardService(f platformtesting.DashboardFields, t *testing.T) (platform.DashboardService, func()) {
|
|
|
|
c, closeFn, err := NewTestClient()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create new bolt client: %v", err)
|
|
|
|
}
|
|
|
|
c.IDGenerator = f.IDGenerator
|
2018-10-16 13:52:52 +00:00
|
|
|
c.WithTime(f.NowFn)
|
2018-05-31 14:44:23 +00:00
|
|
|
ctx := context.TODO()
|
|
|
|
for _, b := range f.Dashboards {
|
|
|
|
if err := c.PutDashboard(ctx, b); err != nil {
|
|
|
|
t.Fatalf("failed to populate dashboards")
|
|
|
|
}
|
|
|
|
}
|
2018-08-07 20:10:05 +00:00
|
|
|
for _, b := range f.Views {
|
|
|
|
if err := c.PutView(ctx, b); err != nil {
|
|
|
|
t.Fatalf("failed to populate views")
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 14:44:23 +00:00
|
|
|
return c, func() {
|
|
|
|
defer closeFn()
|
|
|
|
for _, b := range f.Dashboards {
|
2018-07-30 14:29:52 +00:00
|
|
|
if err := c.DeleteDashboard(ctx, b.ID); err != nil {
|
2018-05-31 14:44:23 +00:00
|
|
|
t.Logf("failed to remove dashboard: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2018-08-07 20:10:05 +00:00
|
|
|
for _, b := range f.Views {
|
|
|
|
if err := c.DeleteView(ctx, b.ID); err != nil {
|
|
|
|
t.Logf("failed to remove view: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 14:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_CreateDashboard(t *testing.T) {
|
|
|
|
platformtesting.CreateDashboard(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_FindDashboardByID(t *testing.T) {
|
|
|
|
platformtesting.FindDashboardByID(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_FindDashboards(t *testing.T) {
|
|
|
|
platformtesting.FindDashboards(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_DeleteDashboard(t *testing.T) {
|
|
|
|
platformtesting.DeleteDashboard(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_UpdateDashboard(t *testing.T) {
|
|
|
|
platformtesting.UpdateDashboard(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_AddDashboardCell(t *testing.T) {
|
|
|
|
platformtesting.AddDashboardCell(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_RemoveDashboardCell(t *testing.T) {
|
|
|
|
platformtesting.RemoveDashboardCell(initDashboardService, t)
|
|
|
|
}
|
2018-08-07 20:10:05 +00:00
|
|
|
|
|
|
|
func TestDashboardService_UpdateDashboardCell(t *testing.T) {
|
|
|
|
platformtesting.UpdateDashboardCell(initDashboardService, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDashboardService_ReplaceDashboardCells(t *testing.T) {
|
|
|
|
platformtesting.ReplaceDashboardCells(initDashboardService, t)
|
|
|
|
}
|