Skip to content

Commit f1967f5

Browse files
committed
adjusted agent test
1 parent 3ebb37d commit f1967f5

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

agent/agent_test.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,50 @@ func init() { //nolint:funlen,gochecknoinits
257257

258258
Context("when the boshAgent fails to get processes for a heartbeat", func() {
259259
BeforeEach(func() {
260+
jobName := "fake-job"
261+
nodeID := "node-id"
262+
jobIndex := 1
263+
specService.Spec = boshas.V1ApplySpec{
264+
Deployment: "FakeDeployment",
265+
JobSpec: boshas.JobSpec{Name: &jobName},
266+
Index: &jobIndex,
267+
NodeID: nodeID,
268+
}
269+
270+
jobSupervisor.StatusStatus = "fake-state"
260271
jobSupervisor.ProcessesError = errors.New("fake-processes-error")
272+
273+
vitalService.GetReturns(boshvitals.Vitals{
274+
Load: []string{"a", "b", "c"},
275+
}, nil)
276+
261277
handler.KeepOnRunning()
278+
handler.SendErr = errors.New("stop")
262279
})
263280

264-
It("returns the error", func() {
281+
It("sends heartbeat with NumberOfProcesses as nil", func() {
265282
err := boshAgent.Run()
266283
Expect(err).To(HaveOccurred())
267-
Expect(err.Error()).To(ContainSubstring("fake-processes-error"))
284+
Expect(err.Error()).To(ContainSubstring("stop"))
285+
Expect(err.Error()).ToNot(ContainSubstring("fake-processes-error"))
286+
287+
expectedJobName := "fake-job"
288+
expectedJobIndex := 1
289+
expectedHb := agent.Heartbeat{
290+
Deployment: "FakeDeployment",
291+
Job: &expectedJobName,
292+
Index: &expectedJobIndex,
293+
JobState: "fake-state",
294+
NodeID: "node-id",
295+
Vitals: boshvitals.Vitals{Load: []string{"a", "b", "c"}},
296+
NumberOfProcesses: nil,
297+
}
298+
299+
Expect(handler.SendInputs()).To(ContainElement(fakembus.SendInput{
300+
Target: boshhandler.HealthMonitor,
301+
Topic: boshhandler.Heartbeat,
302+
Message: expectedHb,
303+
}))
268304
})
269305
})
270306

0 commit comments

Comments
 (0)