Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type InstanceAlert struct {
NetworkIn int `json:"network_in"`
NetworkOut int `json:"network_out"`
TransferQuota int `json:"transfer_quota"`
SystemAlerts []int `json:"system_alerts,omitempty"`
UserAlerts []int `json:"user_alerts,omitempty"`
SystemAlerts []int `json:"system_alerts,omitzero"`
UserAlerts []int `json:"user_alerts,omitzero"`
}

// InstanceBackup represents backup settings for an instance
Expand Down Expand Up @@ -230,8 +230,8 @@ type InstanceCreateOptions struct {

// InstanceACLPAlertsOptions represents ACLP alerts options for instance creation and cloning.
type InstanceACLPAlertsOptions struct {
SystemAlerts []int `json:"system_alerts,omitempty"`
UserAlerts []int `json:"user_alerts,omitempty"`
SystemAlerts []int `json:"system_alerts,omitzero"`
UserAlerts []int `json:"user_alerts,omitzero"`
}

// InstanceCreatePlacementGroupOptions represents the placement group
Expand Down
10 changes: 5 additions & 5 deletions test/unit/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestInstances_List(t *testing.T) {
require.NotNil(t, linode.PlacementGroup.MigratingTo)
assert.Equal(t, 2468, *linode.PlacementGroup.MigratingTo)
assert.Equal(t, "linode/migrate", linode.MaintenancePolicy)
if len(linode.Alerts.SystemAlerts) > 2 {
if len(linode.Alerts.SystemAlerts) >= 2 {
assert.Equal(t, 123, linode.Alerts.SystemAlerts[0])
assert.Equal(t, 456, linode.Alerts.SystemAlerts[1])
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestInstance_Get(t *testing.T) {
assert.Equal(t, "linode/migrate", instance.MaintenancePolicy)
require.NotNil(t, instance.PlacementGroup.MigratingTo)
assert.Equal(t, 2468, *instance.PlacementGroup.MigratingTo)
if len(instance.Alerts.SystemAlerts) > 2 {
if len(instance.Alerts.SystemAlerts) >= 2 {
assert.Equal(t, 123, instance.Alerts.SystemAlerts[0])
assert.Equal(t, 456, instance.Alerts.SystemAlerts[1])
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestInstance_Create(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "new-instance", instance.Label)
assert.Equal(t, "linode/migrate", instance.MaintenancePolicy)
if len(instance.Alerts.SystemAlerts) > 2 {
if len(instance.Alerts.SystemAlerts) >= 2 {
assert.Equal(t, 123, instance.Alerts.SystemAlerts[0])
assert.Equal(t, 456, instance.Alerts.SystemAlerts[1])
}
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestInstance_Update(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "updated-instance", instance.Label)
assert.Equal(t, "linode/power_off_on", instance.MaintenancePolicy)
if len(instance.Alerts.SystemAlerts) > 2 {
if len(instance.Alerts.SystemAlerts) >= 2 {
assert.Equal(t, 123, instance.Alerts.SystemAlerts[0])
assert.Equal(t, 456, instance.Alerts.SystemAlerts[1])
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestInstance_Clone(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "cloned-instance", instance.Label)
assert.Equal(t, "linode/migrate", instance.MaintenancePolicy)
if len(instance.Alerts.SystemAlerts) > 2 {
if len(instance.Alerts.SystemAlerts) >= 2 {
assert.Equal(t, 123, instance.Alerts.SystemAlerts[0])
assert.Equal(t, 456, instance.Alerts.SystemAlerts[1])
}
Expand Down
Loading