Exemplo n.º 1
0
		It("sends a limit cpu request", func() {
			err := container.LimitCPU(garden.CPULimits{
				LimitInShares: 1,
			})
			Ω(err).ShouldNot(HaveOccurred())

			handle, limits := fakeConnection.LimitCPUArgsForCall(0)
			Ω(handle).Should(Equal("some-handle"))
			Ω(limits).Should(Equal(garden.CPULimits{LimitInShares: 1}))
		})

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

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

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

	Describe("LimitDisk", func() {
		It("sends a limit bandwidth request", func() {
			err := container.LimitDisk(garden.DiskLimits{
				ByteHard: 1,
			})
			Ω(err).ShouldNot(HaveOccurred())
Exemplo n.º 2
0
	Describe("LimitCPU", func() {
		handle := "suitcase"

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

		var gotLimits garden.CPULimits

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

				calledHandle, calledLimits := innerConnection.LimitCPUArgsForCall(0)
				Ω(calledHandle).Should(Equal(handle))
				Ω(calledLimits).Should(Equal(limits))
			})

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