err := agentClient.Stop() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("connection is bad")) }) }) }) }) Describe("Ping", func() { Context("when agent responds with a value", func() { BeforeEach(func() { fakeHTTPClient.SetPostBehavior(`{"value":"pong"}`, 200, nil) }) It("makes a POST request to the endpoint", func() { _, err := agentClient.Ping() Expect(err).ToNot(HaveOccurred()) Expect(fakeHTTPClient.PostInputs).To(HaveLen(1)) Expect(fakeHTTPClient.PostInputs[0].Endpoint).To(Equal("http://localhost:6305/agent")) var request AgentRequestMessage err = json.Unmarshal(fakeHTTPClient.PostInputs[0].Payload, &request) Expect(err).ToNot(HaveOccurred()) Expect(request).To(Equal(AgentRequestMessage{ Method: "ping", Arguments: []interface{}{}, ReplyTo: "fake-uuid", })) })