@@ -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 (
@@ -90,12 +94,12 @@ var _ = Describe("Updater", func() {
90
94
It ("should support a mix of standard and custom status updates" , func () {
91
95
u .UpdateStatus (EnsureCondition (conditions .Deployed (corev1 .ConditionTrue , "" , "" )))
92
96
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
93
- Expect (unstructured .SetNestedMap (uSt .Object , map [ string ] interface {}{ "bar" : "baz" } , "foo " )).To (Succeed ())
97
+ Expect (unstructured .SetNestedField (uSt .Object , replicasStatus , "replicas " )).To (Succeed ())
94
98
return true
95
99
})
96
100
u .UpdateStatus (EnsureCondition (conditions .Irreconcilable (corev1 .ConditionFalse , "" , "" )))
97
101
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
98
- Expect (unstructured .SetNestedField (uSt .Object , "quux" , "foo" , "qux " )).To (Succeed ())
102
+ Expect (unstructured .SetNestedField (uSt .Object , availableReplicasStatus , "availableReplicas " )).To (Succeed ())
99
103
return true
100
104
})
101
105
u .UpdateStatus (EnsureCondition (conditions .Initialized (corev1 .ConditionTrue , "" , "" )))
@@ -107,20 +111,20 @@ var _ = Describe("Updater", func() {
107
111
Expect (found ).To (BeFalse ())
108
112
Expect (err ).To (Not (HaveOccurred ()))
109
113
110
- val , found , err := unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
111
- Expect (val ).To (Equal ("baz" ))
114
+ val , found , err := unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
115
+ Expect (val ).To (Equal (replicasStatus ))
112
116
Expect (found ).To (BeTrue ())
113
117
Expect (err ).To (Not (HaveOccurred ()))
114
118
115
- val , found , err = unstructured .NestedString (obj .Object , "status" , "foo" , "qux " )
116
- Expect (val ).To (Equal ("quux" ))
119
+ val , found , err = unstructured .NestedInt64 (obj .Object , "status" , "availableReplicas " )
120
+ Expect (val ).To (Equal (availableReplicasStatus ))
117
121
Expect (found ).To (BeTrue ())
118
122
Expect (err ).To (Not (HaveOccurred ()))
119
123
})
120
124
121
125
It ("should preserve any custom status across multiple apply calls" , func () {
122
126
u .UpdateStatusCustom (func (uSt * unstructured.Unstructured ) bool {
123
- Expect (unstructured .SetNestedMap (uSt .Object , map [ string ] interface {}{ "bar" : "baz" } , "foo " )).To (Succeed ())
127
+ Expect (unstructured .SetNestedField (uSt .Object , int64 ( 5 ) , "replicas " )).To (Succeed ())
124
128
return true
125
129
})
126
130
Expect (u .Apply (context .TODO (), obj )).To (Succeed ())
@@ -131,8 +135,8 @@ var _ = Describe("Updater", func() {
131
135
Expect (found ).To (BeFalse ())
132
136
Expect (err ).To (Not (HaveOccurred ()))
133
137
134
- val , found , err := unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
135
- Expect (val ).To (Equal ("baz" ))
138
+ val , found , err := unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
139
+ Expect (val ).To (Equal (replicasStatus ))
136
140
Expect (found ).To (BeTrue ())
137
141
Expect (err ).To (Succeed ())
138
142
@@ -146,8 +150,8 @@ var _ = Describe("Updater", func() {
146
150
Expect (found ).To (BeFalse ())
147
151
Expect (err ).To (Not (HaveOccurred ()))
148
152
149
- val , found , err = unstructured .NestedString (obj .Object , "status" , "foo" , "bar " )
150
- Expect (val ).To (Equal ("baz" ))
153
+ val , found , err = unstructured .NestedInt64 (obj .Object , "status" , "replicas " )
154
+ Expect (val ).To (Equal (replicasStatus ))
151
155
Expect (found ).To (BeTrue ())
152
156
Expect (err ).To (Succeed ())
153
157
})
0 commit comments