File: monitor_services_test.go

package info (click to toggle)
golang-github-linode-linodego 1.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,112 kB
  • sloc: makefile: 96; sh: 52; python: 24
file content (50 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download
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
package integration

import (
	"context"
	"testing"

	"github.com/linode/linodego"
	"github.com/stretchr/testify/require"
)

func TestMonitorServices_Get_smoke(t *testing.T) {
	client, teardown := createTestClient(t, "fixtures/TestMonitorServices_Get")
	defer teardown()

	// List the all the regsitered ACLP services
	monitorServicesClientList, listErr := client.ListMonitorServices(context.Background(), nil)
	if listErr != nil {
		t.Errorf("Error listing monitor services:%s", listErr)
	}

	// found := false
	for _, services := range monitorServicesClientList {
		validateServiceTypes(t, services)
	}

	// Get the details of the registered ACLP services based on serviceType
	monitorServicesClient, getErr := client.ListMonitorServiceByType(context.Background(), "dbaas", nil)
	if getErr != nil {
		t.Errorf("Error getting monitor services : %s", getErr)
	}

	found := false
	for _, element := range monitorServicesClient {
		if element.ServiceType == "dbaas" {
			found = true
		}
	}

	if !found {
		t.Errorf("Monitor service not found in list.")
	}
}

func validateServiceTypes(
	t *testing.T,
	serviceType linodego.MonitorService,
) {
	require.NotEmpty(t, serviceType.ServiceType)
	require.NotEmpty(t, serviceType.Label)
}