File: monitor_services_metrics_definition_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 (30 lines) | stat: -rw-r--r-- 1,127 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
package unit

import (
	"context"
	"testing"

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

func TestListMonitorMetricDefinitionsByType(t *testing.T) {
	// Load the mock fixture for monitor_service_metrics
	fixtureData, err := fixtures.GetFixture("monitor_service_metrics")
	assert.NoError(t, err, "Expected no error when getting fixture")

	var base ClientBaseCase
	base.SetUp(t)
	defer base.TearDown(t)

	// Mock the GET request for the monitor metric-definitions by type (dbaas)
	base.MockGet("monitor/services/dbaas/metric-definitions", fixtureData)

	// Call the ListMonitorMetricsDefinitionByServiceType method
	clients, err := base.Client.ListMonitorMetricsDefinitionByServiceType(context.Background(), "dbaas", &linodego.ListOptions{})
	assert.NoError(t, err, "Expected no error when listing monitor metric-definitions by type")
	assert.NotEmpty(t, clients, "Expected non-empty monitor metric-definitions list")

	assert.Equal(t, "cpu_usage", clients[0].Metric, "Expected Metric to match")
	assert.Equal(t, linodego.MetricType("gauge"), clients[0].MetricType, "Expected MetricType to match")
}