@@ -35,7 +35,11 @@ import (
35
35
"github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions"
36
36
)
37
37
38
- const testFinalizer = "testFinalizer"
38
+ const (
39
+ testFinalizer = "testFinalizer"
40
+ availableReplicasStatus = int64 (3 )
41
+ replicasStatus = int64 (5 )
42
+ )
39
43
40
44
var _ = Describe ("Updater" , func () {
41
45
var (
@@ -112,12 +116,12 @@ var _ = Describe("Updater", func() {
112
116
It ("should support a mix of standard and custom status updates" , func () {
113
117
u .UpdateStatus (EnsureCondition (conditions .Deployed (corev1 .ConditionTrue , "" , "" )))
114
118
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
115
- Expect (unstructured .SetNestedMap (uSt .Object , map [ string ] interface {}{ "bar" : "baz" } , "foo " )).To (Succeed ())
119
+ Expect (unstructured .SetNestedField (uSt .Object , replicasStatus , "replicas " )).To (Succeed ())
116
120
return true
117
121
})
118
122
u .UpdateStatus (EnsureCondition (conditions .Irreconcilable (corev1 .ConditionFalse , "" , "" )))
119
123
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
120
- Expect (unstructured .SetNestedField (uSt .Object , "quux" , "foo" , "qux " )).To (Succeed ())
124
+ Expect (unstructured .SetNestedField (uSt .Object , availableReplicasStatus , "availableReplicas " )).To (Succeed ())
121
125
return true
122
126
})
123
127
u .UpdateStatus (EnsureCondition (conditions .Initialized (corev1 .ConditionTrue , "" , "" )))
@@ -129,20 +133,20 @@ var _ = Describe("Updater", func() {
129
133
Expect (found ).To (BeFalse ())
130
134
Expect (err ).To (Not (HaveOccurred ()))
131
135
132
- val , found , err := unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
133
- Expect (val ).To (Equal ("baz" ))
136
+ val , found , err := unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
137
+ Expect (val ).To (Equal (replicasStatus ))
134
138
Expect (found ).To (BeTrue ())
135
139
Expect (err ).To (Not (HaveOccurred ()))
136
140
137
- val , found , err = unstructured .NestedString (obj .Object , "status" , "foo" , "qux " )
138
- Expect (val ).To (Equal ("quux" ))
141
+ val , found , err = unstructured .NestedInt64 (obj .Object , "status" , "availableReplicas " )
142
+ Expect (val ).To (Equal (availableReplicasStatus ))
139
143
Expect (found ).To (BeTrue ())
140
144
Expect (err ).To (Not (HaveOccurred ()))
141
145
})
142
146
143
147
It ("should preserve any custom status across multiple apply calls" , func () {
144
148
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
145
- Expect (unstructured .SetNestedMap (uSt .Object , map [ string ] interface {}{ "bar" : "baz" } , "foo " )).To (Succeed ())
149
+ Expect (unstructured .SetNestedField (uSt .Object , int64 ( 5 ) , "replicas " )).To (Succeed ())
146
150
return true
147
151
})
148
152
Expect (u .Apply (context .TODO (), obj )).To (Succeed ())
@@ -153,8 +157,8 @@ var _ = Describe("Updater", func() {
153
157
Expect (found ).To (BeFalse ())
154
158
Expect (err ).To (Not (HaveOccurred ()))
155
159
156
- val , found , err := unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
157
- Expect (val ).To (Equal ("baz" ))
160
+ val , found , err := unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
161
+ Expect (val ).To (Equal (replicasStatus ))
158
162
Expect (found ).To (BeTrue ())
159
163
Expect (err ).To (Succeed ())
160
164
@@ -168,8 +172,8 @@ var _ = Describe("Updater", func() {
168
172
Expect (found ).To (BeFalse ())
169
173
Expect (err ).To (Not (HaveOccurred ()))
170
174
171
- val , found , err = unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
172
- Expect (val ).To (Equal ("baz" ))
175
+ val , found , err = unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
176
+ Expect (val ).To (Equal (replicasStatus ))
173
177
Expect (found ).To (BeTrue ())
174
178
Expect (err ).To (Succeed ())
175
179
})
0 commit comments