コード例 #1
0
ファイル: vm_test.go プロジェクト: vestel/bosh-init
		Context("when starting an agent fails", func() {
			BeforeEach(func() {
				fakeAgentClient.SetStartBehavior(errors.New("fake-start-error"))
			})

			It("returns an error", func() {
				err := vm.Start()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-start-error"))
			})
		})
	})

	Describe("WaitToBeRunning", func() {
		BeforeEach(func() {
			fakeAgentClient.SetGetStateBehavior(biagentclient.AgentState{JobState: "pending"}, nil)
			fakeAgentClient.SetGetStateBehavior(biagentclient.AgentState{JobState: "pending"}, nil)
			fakeAgentClient.SetGetStateBehavior(biagentclient.AgentState{JobState: "running"}, nil)
		})

		It("waits until agent reports state as running", func() {
			err := vm.WaitToBeRunning(5, 0)
			Expect(err).ToNot(HaveOccurred())
			Expect(fakeAgentClient.GetStateCalledTimes).To(Equal(3))
		})
	})

	Describe("AttachDisk", func() {
		var disk *fakebidisk.FakeDisk

		BeforeEach(func() {
コード例 #2
0
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())
				Expect(isRetryable).To(BeFalse())
				Expect(err.Error()).To(ContainSubstring("fake-get-state-error"))
				Expect(fakeAgentClient.GetStateCalledTimes).To(Equal(1))
			})
		})

		Context("when get_state returns state as pending", func() {
			BeforeEach(func() {
				fakeAgentClient.SetGetStateBehavior(AgentState{JobState: "pending"}, nil)
			})