Exemplo n.º 1
0
				},
				Log: true,
			})).Should(Succeed())

			h, rule := fakeConnection.NetOutArgsForCall(0)
			Ω(h).Should(Equal("some-handle"))

			Ω(rule.Networks).Should(HaveLen(1))
			Ω(rule.Networks[0]).Should(Equal(garden.IPRange{Start: net.ParseIP("1.2.3.4"), End: net.ParseIP("1.2.3.4")}))

			Ω(rule.Ports).Should(HaveLen(1))
			Ω(rule.Ports[0]).Should(Equal(garden.PortRange{Start: 12, End: 24}))

			Ω(rule.Log).Should(Equal(true))
		})
	})

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

		BeforeEach(func() {
			fakeConnection.NetOutReturns(disaster)
		})

		It("returns the error", func() {
			err := container.NetOut(garden.NetOutRule{})
			Ω(err).Should(Equal(disaster))
		})
	})
})
Exemplo n.º 2
0
			})
		})
	})

	Describe("NetOut", func() {
		netOutRule := garden.NetOutRule{
			Protocol: garden.ProtocolTCP,
			Ports: []garden.PortRange{
				garden.PortRangeFromPort(13253),
			},
		}

		itRetries(func() error {
			return conn.NetOut("la-contineur", netOutRule)
		}, func(err error) {
			innerConnection.NetOutReturns(err)
		}, func() int {
			return innerConnection.NetOutCallCount()
		}, func() {
			It("calls through to garden", func() {
				Ω(innerConnection.NetOutCallCount()).Should(Equal(1))

				handle, calledNetOutRule := innerConnection.NetOutArgsForCall(0)
				Ω(handle).Should(Equal("la-contineur"))
				Ω(calledNetOutRule).Should(Equal(netOutRule))
			})
		})
	})

	Describe("CurrentBandwidthLimits", func() {
		handle := "suitcase"