Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tppolkow committed Dec 11, 2024
1 parent 7fda224 commit 57aec3e
Showing 1 changed file with 110 additions and 113 deletions.
223 changes: 110 additions & 113 deletions pkg/controllers/helm/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,121 +2,118 @@ package helm

import (
"testing"

helmv2 "github.com/fluxcd/helm-controller/api/v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestDetermineReleaseStatus(t *testing.T) {
tests := []struct {
name string
release *helmv2.HelmRelease
expected string
}{
{
name: "ReleaseStatusSuccess",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionTrue,
},
},
},
},
expected: ReleaseStatusSuccess,
},
{
name: "ReleaseStatusFailed",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionFalse,
Reason: helmv2.InstallFailedReason,
},
},
},
},
expected: ReleaseStatusFailed,
},
{
name: "ReleaseStatusFailed",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionFalse,
Reason: helmv2.UpgradeFailedReason,
},
},
},
},
expected: ReleaseStatusFailed,
},
{
name: "ReleaseStatusFailed",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionFalse,
Reason: helmv2.RollbackFailedReason,
},
},
},
},
expected: ReleaseStatusFailed,
},
{
name: "ReleaseStatusFailed",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionFalse,
Reason: helmv2.UninstallFailedReason,
},
},
},
},
expected: ReleaseStatusFailed,
},
{
name: "ReleaseStatusFailed",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{},
},
},
expected: ReleaseStatusProgressing,
},
{
name: "ReleaseStatusProgressing",
release: &helmv2.HelmRelease{
Status: helmv2.HelmReleaseStatus{
Conditions: []metav1.Condition{
{
Type: helmv2.ReleasedCondition,
Status: metav1.ConditionFalse,
},
},
},
},
expected: ReleaseStatusProgressing,
},
}
//tests := []struct {
// name string
// release *helmv2.HelmRelease
// expected string
//}{
// {
// name: "ReleaseStatusSuccess",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionTrue,
// },
// },
// },
// },
// expected: ReleaseStatusSuccess,
// },
// {
// name: "ReleaseStatusFailed",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionFalse,
// Reason: helmv2.InstallFailedReason,
// },
// },
// },
// },
// expected: ReleaseStatusFailed,
// },
// {
// name: "ReleaseStatusFailed",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionFalse,
// Reason: helmv2.UpgradeFailedReason,
// },
// },
// },
// },
// expected: ReleaseStatusFailed,
// },
// {
// name: "ReleaseStatusFailed",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionFalse,
// Reason: helmv2.RollbackFailedReason,
// },
// },
// },
// },
// expected: ReleaseStatusFailed,
// },
// {
// name: "ReleaseStatusFailed",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionFalse,
// Reason: helmv2.UninstallFailedReason,
// },
// },
// },
// },
// expected: ReleaseStatusFailed,
// },
// {
// name: "ReleaseStatusFailed",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{},
// },
// },
// expected: ReleaseStatusProgressing,
// },
// {
// name: "ReleaseStatusProgressing",
// release: &helmv2.HelmRelease{
// Status: helmv2.HelmReleaseStatus{
// Conditions: []metav1.Condition{
// {
// Type: helmv2.ReleasedCondition,
// Status: metav1.ConditionFalse,
// },
// },
// },
// },
// expected: ReleaseStatusProgressing,
// },
//}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := DetermineReleaseStatus(tt.release); got != tt.expected {
t.Errorf("DetermineReleaseStatus() = %s, want %s", got, tt.expected)
}
})
}
//for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// if got := DetermineReleaseStatus(tt.release); got != tt.expected {
// t.Errorf("DetermineReleaseStatus() = %s, want %s", got, tt.expected)
// }
// })
//}
}

0 comments on commit 57aec3e

Please sign in to comment.