@@ -21,24 +21,16 @@ func TestUpdateConfig(t *testing.T) {
2121 t .Parallel ()
2222
2323 tests := []struct {
24- name string
25- configApplied bool
26- expErr bool
24+ name string
25+ expErr bool
2726 }{
2827 {
29- name : "success" ,
30- configApplied : true ,
31- expErr : false ,
28+ name : "success" ,
29+ expErr : false ,
3230 },
3331 {
34- name : "error returned from agent" ,
35- configApplied : true ,
36- expErr : true ,
37- },
38- {
39- name : "configuration not applied" ,
40- configApplied : false ,
41- expErr : false ,
32+ name : "error returned from agent" ,
33+ expErr : true ,
4234 },
4335 }
4436
@@ -48,7 +40,7 @@ func TestUpdateConfig(t *testing.T) {
4840 g := NewWithT (t )
4941
5042 fakeBroadcaster := & broadcastfakes.FakeBroadcaster {}
51- fakeBroadcaster .SendReturns (test . configApplied )
43+ fakeBroadcaster .SendReturns (true )
5244
5345 plus := false
5446 updater := NewNginxUpdater (logr .Discard (), fake .NewFakeClient (), & status.Queue {}, nil , plus )
@@ -70,9 +62,9 @@ func TestUpdateConfig(t *testing.T) {
7062 deployment .SetPodErrorStatus ("pod1" , testErr )
7163 }
7264
73- applied := updater .UpdateConfig (deployment , []File {file })
65+ updater .UpdateConfig (deployment , []File {file })
7466
75- g .Expect (applied ) .To (Equal (test . configApplied ))
67+ g .Expect (fakeBroadcaster . SendCallCount ()) .To (Equal (1 ))
7668 g .Expect (deployment .GetFile (file .Meta .Name , file .Meta .Hash )).To (Equal (file .Contents ))
7769
7870 if test .expErr {
@@ -114,10 +106,9 @@ func TestUpdateConfig_NoChange(t *testing.T) {
114106 deployment .SetFiles ([]File {file })
115107
116108 // Call UpdateConfig with the same files
117- applied := updater .UpdateConfig (deployment , []File {file })
109+ updater .UpdateConfig (deployment , []File {file })
118110
119111 // Verify that no new configuration was sent
120- g .Expect (applied ).To (BeFalse ())
121112 g .Expect (fakeBroadcaster .SendCallCount ()).To (Equal (0 ))
122113}
123114
@@ -128,43 +119,31 @@ func TestUpdateUpstreamServers(t *testing.T) {
128119 name string
129120 buildUpstreams bool
130121 plus bool
131- configApplied bool
132122 expErr bool
133123 }{
134124 {
135125 name : "success" ,
136126 plus : true ,
137127 buildUpstreams : true ,
138- configApplied : true ,
139128 expErr : false ,
140129 },
141130 {
142131 name : "no upstreams to apply" ,
143132 plus : true ,
144133 buildUpstreams : false ,
145- configApplied : false ,
146134 expErr : false ,
147135 },
148136 {
149- name : "not running nginx plus" ,
150- plus : false ,
151- configApplied : false ,
152- expErr : false ,
137+ name : "not running nginx plus" ,
138+ plus : false ,
139+ expErr : false ,
153140 },
154141 {
155142 name : "error returned from agent" ,
156143 plus : true ,
157144 buildUpstreams : true ,
158- configApplied : true ,
159145 expErr : true ,
160146 },
161- {
162- name : "configuration not applied" ,
163- plus : true ,
164- buildUpstreams : true ,
165- configApplied : false ,
166- expErr : false ,
167- },
168147 }
169148
170149 for _ , test := range tests {
@@ -173,7 +152,6 @@ func TestUpdateUpstreamServers(t *testing.T) {
173152 g := NewWithT (t )
174153
175154 fakeBroadcaster := & broadcastfakes.FakeBroadcaster {}
176- fakeBroadcaster .SendReturns (test .configApplied )
177155
178156 updater := NewNginxUpdater (logr .Discard (), fake .NewFakeClient (), & status.Queue {}, nil , test .plus )
179157 updater .retryTimeout = 0
@@ -215,8 +193,7 @@ func TestUpdateUpstreamServers(t *testing.T) {
215193 }
216194 }
217195
218- applied := updater .UpdateUpstreamServers (deployment , conf )
219- g .Expect (applied ).To (Equal (test .configApplied ))
196+ updater .UpdateUpstreamServers (deployment , conf )
220197
221198 expActions := make ([]* pb.NGINXPlusAction , 0 )
222199 if test .buildUpstreams {
@@ -254,8 +231,10 @@ func TestUpdateUpstreamServers(t *testing.T) {
254231
255232 if ! test .plus {
256233 g .Expect (deployment .GetNGINXPlusActions ()).To (BeNil ())
234+ g .Expect (fakeBroadcaster .SendCallCount ()).To (Equal (0 ))
257235 } else if test .buildUpstreams {
258236 g .Expect (deployment .GetNGINXPlusActions ()).To (Equal (expActions ))
237+ g .Expect (fakeBroadcaster .SendCallCount ()).To (Equal (2 ))
259238 }
260239
261240 if test .expErr {
@@ -347,10 +326,9 @@ func TestUpdateUpstreamServers_NoChange(t *testing.T) {
347326 deployment .SetNGINXPlusActions (initialActions )
348327
349328 // Call UpdateUpstreamServers with the same configuration
350- applied := updater .UpdateUpstreamServers (deployment , conf )
329+ updater .UpdateUpstreamServers (deployment , conf )
351330
352331 // Verify that no new actions were sent
353- g .Expect (applied ).To (BeFalse ())
354332 g .Expect (fakeBroadcaster .SendCallCount ()).To (Equal (0 ))
355333}
356334
0 commit comments