Updated subscription date
This commit is contained in:
+10
-5
@@ -430,13 +430,18 @@ func (r *PveSdnResource) GetStatusNumeric() float64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetActiveNumeric returns the numeric state of a subscription.
|
||||
// Returns 1 if the subscription status is "active", otherwise returns 0.
|
||||
func (r *PveSubscription) GetActiveNumeric() float64 {
|
||||
if r.Status == "active" {
|
||||
// GetStatusNumeric returns the numeric state of a subscription.
|
||||
// A missing subscription is 0, an active subscription is 1, and an expired
|
||||
// or otherwise unusable subscription is 2.
|
||||
func (r *PveSubscription) GetStatusNumeric() float64 {
|
||||
switch r.Status {
|
||||
case "notfound":
|
||||
return 0
|
||||
case "active":
|
||||
return 1
|
||||
default:
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetSmartPassedState returns the numeric health state of a disk.
|
||||
|
||||
@@ -28,3 +28,27 @@ func TestPveClusterStatusGetClusterModeNumeric(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPveSubscriptionGetStatusNumeric(t *testing.T) {
|
||||
tests := []struct {
|
||||
status string
|
||||
want float64
|
||||
}{
|
||||
{status: "notfound", want: 0},
|
||||
{status: "active", want: 1},
|
||||
{status: "expired", want: 2},
|
||||
{status: "invalid", want: 2},
|
||||
{status: "suspended", want: 2},
|
||||
{status: "new", want: 2},
|
||||
{status: "unknown", want: 2},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.status, func(t *testing.T) {
|
||||
subscription := PveSubscription{Status: tt.status}
|
||||
if got := subscription.GetStatusNumeric(); got != tt.want {
|
||||
t.Fatalf("GetStatusNumeric() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user