Skip to content

Commit dd0cf13

Browse files
committed
Create negative test cases for Pulse Metrics
1 parent cee3651 commit dd0cf13

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

test/integration/monitor_dashboards_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -58,6 +59,15 @@ func TestMonitorDashboards_Get_smoke(t *testing.T) {
5859
}
5960
}
6061

62+
func TestMonitorDashboards_GetNotExistingDashboardID(t *testing.T) {
63+
client, teardown := createTestClient(t, "fixtures/TestMonitorDashboards_Get")
64+
defer teardown()
65+
66+
_, getErr := client.GetMonitorDashboard(context.Background(), 999999)
67+
require.Error(t, getErr)
68+
assert.Contains(t, getErr.Error(), "[404] Not found")
69+
}
70+
6171
func validateDashboards(
6272
t *testing.T,
6373
dashboards linodego.MonitorDashboard,

test/integration/monitor_services_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -41,6 +42,15 @@ func TestMonitorServices_Get_smoke(t *testing.T) {
4142
}
4243
}
4344

45+
func TestMonitorServices_GetNotAllowedServiceType(t *testing.T) {
46+
client, teardown := createTestClient(t, "fixtures/TestMonitorServices_Get")
47+
defer teardown()
48+
49+
_, getErr := client.ListMonitorServiceByType(context.Background(), "saas", nil)
50+
require.Error(t, getErr)
51+
assert.Contains(t, getErr.Error(), "[404] Not found")
52+
}
53+
4454
func validateServiceTypes(
4555
t *testing.T,
4656
serviceType linodego.MonitorService,

test/integration/monitor_services_token_creation_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -46,6 +47,21 @@ func TestMonitorServicesTokenCreation_Get_smoke(t *testing.T) {
4647
validateToken(t, *token)
4748
}
4849

50+
func TestMonitorServicesTokenCreation_TryCreateTokenWithInvalidEntityID(t *testing.T) {
51+
var entityIDs []any
52+
entityIDs = append(entityIDs, 999999999)
53+
54+
client, teardown := createTestClient(t, "fixtures/TestServiceToken_POST")
55+
defer teardown()
56+
createOptsWithInvalidID := linodego.MonitorTokenCreateOptions{
57+
EntityIDs: entityIDs,
58+
}
59+
_, createErr := client.CreateMonitorServiceTokenForServiceType(context.Background(), "dbaas", createOptsWithInvalidID)
60+
require.Error(t, createErr)
61+
assert.Contains(t, createErr.Error(), "[403]")
62+
assert.Contains(t, createErr.Error(), "The following entity_ids are not valid - [999999999]")
63+
}
64+
4965
func validateToken(
5066
t *testing.T,
5167
token linodego.MonitorServiceToken,

0 commit comments

Comments
 (0)