1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
package integration
import (
"context"
"testing"
"github.com/linode/linodego"
"github.com/stretchr/testify/require"
)
func TestMonitorDashboards_Get_smoke(t *testing.T) {
client, teardown := createTestClient(t, "fixtures/TestMonitorDashboards_Get")
defer teardown()
// Get list of all ACLP Dashboards
monitorDashboardsClientList, listErr := client.ListMonitorDashboards(context.Background(), nil)
if listErr != nil {
t.Errorf("Error listing monitor dashboards:%s", listErr)
}
// validating the details of the Dashboards
for _, dashboards := range monitorDashboardsClientList {
validateDashboards(t, dashboards)
}
// Get an ACLP Dashboard by dashboardID
monitorDashhboardClient, getErr := client.GetMonitorDashboard(context.Background(), 1)
if getErr != nil {
t.Errorf("Error getting dashboard by ID :%s", getErr)
}
found := false
for _, element := range monitorDashboardsClientList {
if element.ServiceType == monitorDashhboardClient.ServiceType {
found = true
}
}
if !found {
t.Errorf("Monitor dashboard not found in list.")
}
// List ACLP Dashboards by serviceType
monitorDashhboardClientST, listErr := client.ListMonitorDashboardsByServiceType(context.Background(), "dbaas", nil)
if listErr != nil {
t.Errorf("Error listing monitor dashboards:%s", listErr)
}
found_st := false
for _, element := range monitorDashhboardClientST {
if element.ServiceType == monitorDashhboardClient.ServiceType {
found_st = true
}
}
if !found_st {
t.Errorf("Monitor dashboard not found in list.")
}
}
func validateDashboards(
t *testing.T,
dashboards linodego.MonitorDashboard,
) {
require.NotEmpty(t, dashboards.ID)
require.NotEmpty(t, dashboards.ServiceType)
require.NotEmpty(t, dashboards.Label)
require.NotEmpty(t, dashboards.Created)
require.NotEmpty(t, dashboards.Updated)
require.NotEmpty(t, dashboards.Widgets)
}
|