package agentclient_test import ( "errors" . "github.com/cloudfoundry/bosh-agent/agentclient" fakeagentclient "github.com/cloudfoundry/bosh-agent/agentclient/fakes" boshretry "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/retrystrategy" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega" ) var _ = Describe("GetStateRetryable", func() { Describe("Attempt", func() { var ( fakeAgentClient *fakeagentclient.FakeAgentClient getStateRetryable boshretry.Retryable ) BeforeEach(func() { fakeAgentClient = fakeagentclient.NewFakeAgentClient() getStateRetryable = NewGetStateRetryable(fakeAgentClient) }) Context("when get_state fails", func() { BeforeEach(func() { fakeAgentClient.SetGetStateBehavior(AgentState{}, errors.New("fake-get-state-error")) }) It("returns an error", func() { isRetryable, err := getStateRetryable.Attempt() Expect(err).To(HaveOccurred())
import ( "errors" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega" boshretry "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/retrystrategy" fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes" . "github.com/cloudfoundry/bosh-agent/platform" ) var _ = Describe("MonitRetryable", func() { var ( cmdRunner *fakesys.FakeCmdRunner monitRetryable boshretry.Retryable ) BeforeEach(func() { cmdRunner = fakesys.NewFakeCmdRunner() monitRetryable = NewMonitRetryable(cmdRunner) }) Describe("Attempt", func() { Context("when starting monit fails", func() { BeforeEach(func() { cmdRunner.AddCmdResult("sv start monit", fakesys.FakeCmdResult{ ExitStatus: 255, Error: errors.New("fake-start-monit-error"), }) })
package agentclient_test import ( "errors" . "github.com/cloudfoundry/bosh-agent/agentclient" fakeagentclient "github.com/cloudfoundry/bosh-agent/agentclient/fakes" boshretry "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/retrystrategy" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo" . "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega" ) var _ = Describe("PingRetryable", func() { Describe("Attempt", func() { var ( fakeAgentClient *fakeagentclient.FakeAgentClient pingRetryable boshretry.Retryable ) BeforeEach(func() { fakeAgentClient = fakeagentclient.NewFakeAgentClient() pingRetryable = NewPingRetryable(fakeAgentClient) }) It("tells the agent client to ping", func() { isRetryable, err := pingRetryable.Attempt() Expect(err).ToNot(HaveOccurred()) Expect(isRetryable).To(BeTrue()) Expect(fakeAgentClient.PingCalledCount).To(Equal(1)) }) Context("when pinging fails", func() {