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