BeforeEach(func() { fakeConnection.WhenNetInning = func(handle string, hostPort, containerPort uint32) (uint32, uint32, error) { return 0, 0, disaster } }) It("returns the error", func() { _, _, err := container.NetIn(123, 456) Ω(err).Should(Equal(disaster)) }) }) }) Describe("NetOut", func() { It("sends a net out request", func() { err := container.NetOut("some-network", 1234) Ω(err).ShouldNot(HaveOccurred()) Ω(fakeConnection.NetOuted("some-handle")).Should(ContainElement( fake_connection.NetOutSpec{ Network: "some-network", Port: 1234, }, )) }) Context("when the request fails", func() { disaster := errors.New("oh no!") BeforeEach(func() { fakeConnection.WhenNetOuting = func(handle string, network string, port uint32) error {