buf := bytes.NewBufferString(fmt.Sprintf("%s\r\n", email)) _, err = buf.WriteTo(writeCloser) if err != nil { return err } return nil } Describe("Reload", func() { It("waits until the job is reloaded", func() { client.Incarnations = []int{1, 1, 1, 2, 3} client.StatusStatus = fakemonit.FakeMonitStatus{ Services: []boshmonit.Service{ boshmonit.Service{Monitored: true, Status: "failing"}, boshmonit.Service{Monitored: true, Status: "running"}, }, Incarnation: 1, } err := monit.Reload() Expect(err).ToNot(HaveOccurred()) Expect(len(runner.RunCommands)).To(Equal(1)) Expect(runner.RunCommands[0]).To(Equal([]string{"monit", "reload"})) Expect(client.StatusCalledTimes).To(Equal(4)) }) It("returns error after monit reloading X times, each time checking incarnation Y times", func() { for i := 0; i < 100; i++ { client.Incarnations = append(client.Incarnations, 1)