コード例 #1
0
ファイル: container_test.go プロジェクト: guanglinlv/garden
			})

			It("returns the error", func() {
				_, err := container.CurrentBandwidthLimits()
				Ω(err).Should(Equal(disaster))
			})
		})
	})

	Describe("CurrentCPULimits", func() {
		It("sends an empty limit request and returns its response", func() {
			limitsToReturn := garden.CPULimits{
				LimitInShares: 1,
			}

			fakeConnection.CurrentCPULimitsReturns(limitsToReturn, nil)

			limits, err := container.CurrentCPULimits()
			Ω(err).ShouldNot(HaveOccurred())

			Ω(limits).Should(Equal(limitsToReturn))
		})

		Context("when the request fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				fakeConnection.CurrentCPULimitsReturns(garden.CPULimits{}, disaster)
			})

			It("returns the error", func() {
コード例 #2
0
	Describe("CurrentCPULimits", func() {
		handle := "suitcase"

		limits := garden.CPULimits{
			LimitInShares: 7,
		}

		var gotLimits garden.CPULimits

		itRetries(func() error {
			var err error
			gotLimits, err = conn.CurrentCPULimits(handle)
			return err
		}, func(err error) {
			innerConnection.CurrentCPULimitsReturns(limits, err)
		}, func() int {
			return innerConnection.CurrentCPULimitsCallCount()
		}, func() {
			It("calls through to garden", func() {
				Ω(innerConnection.CurrentCPULimitsCallCount()).Should(Equal(1))

				calledHandle := innerConnection.CurrentCPULimitsArgsForCall(0)
				Ω(calledHandle).Should(Equal(handle))
			})

			It("returns the limits", func() {
				Ω(gotLimits).Should(Equal(limits))
			})
		})
	})