@@ -51,15 +51,18 @@ var _ = Describe("NGINX Runtime Manager", func() {
51
51
manager = runtime .NewManagerImpl (ngxPlusClient , metrics , zap .New (), process , verifyClient )
52
52
})
53
53
54
- It ("NGINX configuration reload is successful" , func () {
55
- Expect (manager .Reload (context .Background (), 1 )).To (Succeed ())
56
-
57
- Expect (process .FindMainProcessCallCount ()).To (Equal (1 ))
58
- Expect (process .ReadFileCallCount ()).To (Equal (1 ))
59
- Expect (process .KillCallCount ()).To (Equal (1 ))
60
- Expect (metrics .IncReloadCountCallCount ()).To (Equal (1 ))
61
- Expect (verifyClient .WaitForCorrectVersionCallCount ()).To (Equal (1 ))
62
- Expect (metrics .ObserveLastReloadTimeCallCount ()).To (Equal (1 ))
54
+ When ("MetricsCollector is nil" , func () {
55
+ It ("NGINX configuration reload is successful" , func () {
56
+ Expect (manager .Reload (context .Background (), 1 )).To (Succeed ())
57
+
58
+ Expect (process .FindMainProcessCallCount ()).To (Equal (1 ))
59
+ Expect (process .ReadFileCallCount ()).To (Equal (1 ))
60
+ Expect (process .KillCallCount ()).To (Equal (1 ))
61
+ Expect (metrics .IncReloadCountCallCount ()).To (Equal (1 ))
62
+ Expect (verifyClient .WaitForCorrectVersionCallCount ()).To (Equal (1 ))
63
+ Expect (metrics .ObserveLastReloadTimeCallCount ()).To (Equal (1 ))
64
+ Expect (metrics .IncReloadErrorsCallCount ()).To (Equal (0 ))
65
+ })
63
66
})
64
67
65
68
When ("NGINX configuration reload is not successful" , func () {
@@ -100,12 +103,22 @@ var _ = Describe("NGINX Runtime Manager", func() {
100
103
Expect (manager .UpdateHTTPServers ("test" , upstreamServers )).To (Succeed ())
101
104
})
102
105
103
- It ("returns no upstreams from NGINX Plus API" , func () {
106
+ It ("returns no upstreams from NGINX Plus API when upstreams are nil " , func () {
104
107
upstreams , err := manager .GetUpstreams ()
105
108
106
109
Expect (err ).To (HaveOccurred ())
107
110
Expect (upstreams ).To (BeEmpty ())
108
111
})
112
+
113
+ It ("returns an error when GetUpstreams fails" , func () {
114
+ ngxPlusClient .GetUpstreamsReturns (nil , errors .New ("failed to get upstreams" ))
115
+
116
+ upstreams , err := manager .GetUpstreams ()
117
+
118
+ Expect (err ).To (HaveOccurred ())
119
+ Expect (err ).To (MatchError ("failed to get upstreams" ))
120
+ Expect (upstreams ).To (BeNil ())
121
+ })
109
122
})
110
123
111
124
When ("not running NGINX plus" , func () {
0 commit comments