Skip to content

Commit

Permalink
Added a bunch of static fixture tests to make it clear that these val…
Browse files Browse the repository at this point in the history
…ues must be exported by the library.

Also tweaked comments.
Both these changes make GoLand stop raising warnings.
  • Loading branch information
JohnSharpe committed Jun 26, 2023
1 parent bb37160 commit c175470
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 25 deletions.
99 changes: 99 additions & 0 deletions fixture_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package rediscloud_api

import (
"github.com/RedisLabs/rediscloud-go-api/service/cloud_accounts"
"github.com/RedisLabs/rediscloud-go-api/service/databases"
"github.com/RedisLabs/rediscloud-go-api/service/subscriptions"
"github.com/stretchr/testify/assert"
"testing"
)

func TestSubcriptionFixtures(t *testing.T) {
assert.Equal(t, "active", subscriptions.SubscriptionStatusActive)
assert.Equal(t, "pending", subscriptions.SubscriptionStatusPending)
assert.Equal(t, "error", subscriptions.SubscriptionStatusError)
assert.Equal(t, "deleting", subscriptions.SubscriptionStatusDeleting)

assert.Equal(t, "initiating-request", subscriptions.VPCPeeringStatusInitiatingRequest)
assert.Equal(t, "active", subscriptions.VPCPeeringStatusActive)
assert.Equal(t, "inactive", subscriptions.VPCPeeringStatusInactive)
assert.Equal(t, "pending-acceptance", subscriptions.VPCPeeringStatusPendingAcceptance)
assert.Equal(t, "failed", subscriptions.VPCPeeringStatusFailed)

assert.Equal(t, "single-region", subscriptions.SubscriptionDeploymentTypeSingleRegion)
assert.Equal(t, "active-active", subscriptions.SubscriptionDeploymentTypeActiveActive)
}

func TestDatabaseFixtures(t *testing.T) {
assert.Equal(t, "active", databases.StatusActive)
assert.Equal(t, "draft", databases.StatusDraft)
assert.Equal(t, "pending", databases.StatusPending)
assert.Equal(t, "rcp-change-pending", databases.StatusRCPChangePending)
assert.Equal(t, "rcp-draft", databases.StatusRCPDraft)
assert.Equal(t, "rcp-active-change-draft", databases.StatusRCPActiveChangeDraft)
assert.Equal(t, "active-change-draft", databases.StatusActiveChangeDraft)
assert.Equal(t, "active-change-pending", databases.StatusActiveChangePending)

assert.Equal(t, "proxy-policy-change-pending", databases.StatusProxyPolicyChangePending)
assert.Equal(t, "proxy-policy-change-draft", databases.StatusProxyPolicyChangeDraft)
assert.Equal(t, "error", databases.StatusError)

assert.Equal(t, []string{databases.MemoryStorageRam, databases.MemoryStorageRamAndFlash}, databases.MemoryStorageValues())
assert.Equal(t, []string{"redis", "memcached"}, databases.ProtocolValues())
assert.Equal(t, []string{
"none",
"aof-every-1-second",
"aof-every-write",
"snapshot-every-1-hour",
"snapshot-every-6-hours",
"snapshot-every-12-hours",
}, databases.DataPersistenceValues())
assert.Equal(t, []string{
"allkeys-lru",
"allkeys-lfu",
"allkeys-random",
"volatile-lru",
"volatile-lfu",
"volatile-random",
"volatile-ttl",
"noeviction",
}, databases.DataEvictionPolicyValues())
assert.Equal(t, []string{
"http",
"redis",
"ftp",
"aws-s3",
"azure-blob-storage",
"google-blob-storage",
}, databases.SourceTypeValues())
assert.Equal(t, []string{
"dataset-size",
"throughput-higher-than",
"throughput-lower-than",
"latency",
"syncsource-error",
"syncsource-lag",
}, databases.AlertNameValues())
assert.Equal(t, []string{
"ftp",
"aws-s3",
"azure-blob-storage",
"google-blob-storage",
}, databases.BackupStorageTypes())
assert.Equal(t, []string{
databases.BackupIntervalEvery24Hours,
databases.BackupIntervalEvery12Hours,
databases.BackupIntervalEvery6Hours,
databases.BackupIntervalEvery4Hours,
databases.BackupIntervalEvery2Hours,
databases.BackupIntervalEvery1Hours,
}, databases.BackupIntervals())
}

func TestCloudAccountFixtures(t *testing.T) {
assert.Equal(t, "active", cloud_accounts.StatusActive)
assert.Equal(t, "draft", cloud_accounts.StatusDraft)
assert.Equal(t, "change-draft", cloud_accounts.StatusChangeDraft)
assert.Equal(t, "error", cloud_accounts.StatusError)
assert.Equal(t, []string{"AWS", "GCP"}, cloud_accounts.ProviderValues())
}
8 changes: 4 additions & 4 deletions service/cloud_accounts/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func (o CloudAccount) String() string {
}

const (
// Active value of the `Status` field in `CloudAccount`
// StatusActive is the active value of the `Status` field in `CloudAccount`
StatusActive = "active"
// Draft value of the `Status` field in `CloudAccount`
// StatusDraft is the draft value of the `Status` field in `CloudAccount`
StatusDraft = "draft"
// Change draft value of the `Status` field in `CloudAccount`
// StatusChangeDraft is the change draft value of the `Status` field in `CloudAccount`
StatusChangeDraft = "change-draft"
// Error value of the `Status` field in `CloudAccount`
// StatusError is the error value of the `Status` field in `CloudAccount`
StatusError = "error"
)

Expand Down
27 changes: 15 additions & 12 deletions service/databases/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,31 @@ func (f *NotFound) Error() string {
}

const (
// Active value of the `Status` field in `Database`
// StatusActive is the active value of the `Status` field in `Database`
StatusActive = "active"
// Draft value of the `Status` field in `Database`
// StatusDraft is the draft value of the `Status` field in `Database`
StatusDraft = "draft"
// Pending value of the `Status` field in `Database`
// StatusPending is the pending value of the `Status` field in `Database`
StatusPending = "pending"
// RCP change pending value of the `Status` field in `Database`
// StatusRCPChangePending is the RCP change pending value of the `Status` field in `Database`
StatusRCPChangePending = "rcp-change-pending"
// RCP draft value of the `Status` field in `Database`
// StatusRCPDraft is the RCP draft value of the `Status` field in `Database`
StatusRCPDraft = "rcp-draft"
// RCP active change draft value of the `Status` field in `Database`
// StatusRCPActiveChangeDraft is the RCP active change draft value of the `Status` field in `Database`
StatusRCPActiveChangeDraft = "rcp-active-change-draft"
// Active change draft value of the `Status` field in `Database`
// StatusActiveChangeDraft is the Active change draft value of the `Status` field in `Database`
StatusActiveChangeDraft = "active-change-draft"
// Active change pending value of the `Status` field in `Database`
// StatusActiveChangePending is the Active change pending value of the `Status` field in `Database`
StatusActiveChangePending = "active-change-pending"
// The below two Proxy Policy states are caused by a change to the 'support_oss_cluster_api' attribute
// Proxy Policy change pending value of the `Status` field in `Database`.

// StatusProxyPolicyChangePending and StatusProxyPolicyChangeDraft
//The below two Proxy Policy states are caused by a change to the 'support_oss_cluster_api' attribute
// StatusProxyPolicyChangePending is the Proxy Policy change pending value of the `Status` field in `Database`.
StatusProxyPolicyChangePending = "proxy-policy-change-pending"
// Proxy Policy change draft value of the `Status` field in `Database`
// StatusProxyPolicyChangeDraft is the Proxy Policy change draft value of the `Status` field in `Database`
StatusProxyPolicyChangeDraft = "proxy-policy-change-draft"
// Error value of the `Status` field in `Database`

// StatusError is the error value of the `Status` field in `Database`
StatusError = "error"
// BackupIntervalEvery24Hours is the schedule to back up once a day
BackupIntervalEvery24Hours = "every-24-hours"
Expand Down
18 changes: 9 additions & 9 deletions service/subscriptions/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,24 @@ func (f *NotFound) Error() string {
}

const (
// Active value of the `Status` field in `Subscription`
// SubscriptionStatusActive is the active value of the `Status` field in `Subscription`
SubscriptionStatusActive = "active"
// Pending value of the `Status` field in `Subscription`
// SubscriptionStatusPending is the pending value of the `Status` field in `Subscription`
SubscriptionStatusPending = "pending"
// Error value of the `Status` field in `Subscription`
// SubscriptionStatusError is the error value of the `Status` field in `Subscription`
SubscriptionStatusError = "error"
// Deleting value of the `Status` field in `Subscription`
// SubscriptionStatusDeleting is the deleting value of the `Status` field in `Subscription`
SubscriptionStatusDeleting = "deleting"

// Initiating request value of the `Status` field in `VPCPeering`
// VPCPeeringStatusInitiatingRequest is the initiating request value of the `Status` field in `VPCPeering`
VPCPeeringStatusInitiatingRequest = "initiating-request"
// Active value of the `Status` field in `VPCPeering`
// VPCPeeringStatusActive is the active value of the `Status` field in `VPCPeering`
VPCPeeringStatusActive = "active"
// Inactive value of the `Status` field in `VPCPeering`
// VPCPeeringStatusInactive is the inactive value of the `Status` field in `VPCPeering`
VPCPeeringStatusInactive = "inactive"
// Pending acceptance value of the `Status` field in `VPCPeering`
// VPCPeeringStatusPendingAcceptance is the pending acceptance value of the `Status` field in `VPCPeering`
VPCPeeringStatusPendingAcceptance = "pending-acceptance"
// Failed value of the `Status` field in `VPCPeering`
// VPCPeeringStatusFailed is the failed value of the `Status` field in `VPCPeering`
VPCPeeringStatusFailed = "failed"

SubscriptionDeploymentTypeSingleRegion = "single-region"
Expand Down

0 comments on commit c175470

Please sign in to comment.