@@ -32,7 +32,11 @@ import (
3232 "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions"
3333)
3434
35- const testFinalizer = "testFinalizer"
35+ const (
36+ testFinalizer = "testFinalizer"
37+ availableReplicasStatus = int64 (3 )
38+ replicasStatus = int64 (5 )
39+ )
3640
3741var _ = Describe ("Updater" , func () {
3842 var (
@@ -90,12 +94,12 @@ var _ = Describe("Updater", func() {
9094 It ("should support a mix of standard and custom status updates" , func () {
9195 u .UpdateStatus (EnsureCondition (conditions .Deployed (corev1 .ConditionTrue , "" , "" )))
9296 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 ())
9498 return true
9599 })
96100 u .UpdateStatus (EnsureCondition (conditions .Irreconcilable (corev1 .ConditionFalse , "" , "" )))
97101 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 ())
99103 return true
100104 })
101105 u .UpdateStatus (EnsureCondition (conditions .Initialized (corev1 .ConditionTrue , "" , "" )))
@@ -107,20 +111,20 @@ var _ = Describe("Updater", func() {
107111 Expect (found ).To (BeFalse ())
108112 Expect (err ).To (Not (HaveOccurred ()))
109113
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 ))
112116 Expect (found ).To (BeTrue ())
113117 Expect (err ).To (Not (HaveOccurred ()))
114118
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 ))
117121 Expect (found ).To (BeTrue ())
118122 Expect (err ).To (Not (HaveOccurred ()))
119123 })
120124
121125 It ("should preserve any custom status across multiple apply calls" , func () {
122126 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 ())
124128 return true
125129 })
126130 Expect (u .Apply (context .TODO (), obj )).To (Succeed ())
@@ -131,8 +135,8 @@ var _ = Describe("Updater", func() {
131135 Expect (found ).To (BeFalse ())
132136 Expect (err ).To (Not (HaveOccurred ()))
133137
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 ))
136140 Expect (found ).To (BeTrue ())
137141 Expect (err ).To (Succeed ())
138142
@@ -146,8 +150,8 @@ var _ = Describe("Updater", func() {
146150 Expect (found ).To (BeFalse ())
147151 Expect (err ).To (Not (HaveOccurred ()))
148152
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 ))
151155 Expect (found ).To (BeTrue ())
152156 Expect (err ).To (Succeed ())
153157 })
0 commit comments