@@ -19,6 +19,7 @@ package action
19
19
import (
20
20
"testing"
21
21
22
+ . "github.com/onsi/gomega"
22
23
"helm.sh/helm/v3/pkg/chart"
23
24
"helm.sh/helm/v3/pkg/chartutil"
24
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -28,11 +29,12 @@ import (
28
29
29
30
func TestMustResetFailures (t * testing.T ) {
30
31
tests := []struct {
31
- name string
32
- obj * v2.HelmRelease
33
- chart * chart.Metadata
34
- values chartutil.Values
35
- want bool
32
+ name string
33
+ obj * v2.HelmRelease
34
+ chart * chart.Metadata
35
+ values chartutil.Values
36
+ want bool
37
+ wantReason string
36
38
}{
37
39
{
38
40
name : "on generation change" ,
@@ -44,7 +46,8 @@ func TestMustResetFailures(t *testing.T) {
44
46
LastAttemptedGeneration : 2 ,
45
47
},
46
48
},
47
- want : true ,
49
+ want : true ,
50
+ wantReason : differentGenerationReason ,
48
51
},
49
52
{
50
53
name : "on revision change" ,
@@ -60,7 +63,8 @@ func TestMustResetFailures(t *testing.T) {
60
63
chart : & chart.Metadata {
61
64
Version : "1.1.0" ,
62
65
},
63
- want : true ,
66
+ want : true ,
67
+ wantReason : differentRevisionReason ,
64
68
},
65
69
{
66
70
name : "on config digest change" ,
@@ -80,7 +84,8 @@ func TestMustResetFailures(t *testing.T) {
80
84
values : chartutil.Values {
81
85
"foo" : "bar" ,
82
86
},
83
- want : true ,
87
+ want : true ,
88
+ wantReason : differentValuesReason ,
84
89
},
85
90
{
86
91
name : "on (deprecated) values checksum change" ,
@@ -100,7 +105,8 @@ func TestMustResetFailures(t *testing.T) {
100
105
values : chartutil.Values {
101
106
"foo" : "bar" ,
102
107
},
103
- want : true ,
108
+ want : true ,
109
+ wantReason : differentValuesReason ,
104
110
},
105
111
{
106
112
name : "without change no reset" ,
@@ -125,9 +131,11 @@ func TestMustResetFailures(t *testing.T) {
125
131
}
126
132
for _ , tt := range tests {
127
133
t .Run (tt .name , func (t * testing.T ) {
128
- if got := MustResetFailures (tt .obj , tt .chart , tt .values ); got != tt .want {
129
- t .Errorf ("MustResetFailures() = %v, want %v" , got , tt .want )
130
- }
134
+ g := NewWithT (t )
135
+
136
+ reason , got := MustResetFailures (tt .obj , tt .chart , tt .values )
137
+ g .Expect (got ).To (Equal (tt .want ))
138
+ g .Expect (reason ).To (Equal (tt .wantReason ))
131
139
})
132
140
}
133
141
}
0 commit comments