Example #1
0
				f, err := ioutil.TempFile("", "")
				Expect(err).NotTo(HaveOccurred())

				config.BridgeName = "bridge"

				Expect(configurer.Apply(config, netnsFD)).To(Succeed())
				Expect(linkConfigurer.SetNsCalledWith.Fd).To(Equal(int(netnsFD.Fd())))

				os.RemoveAll(f.Name())
			})

			Context("When moving the container interface into the namespace fails", func() {
				It("returns a wrapped error", func() {
					config.BridgeName = "bridge"

					linkConfigurer.SetNsReturns = errors.New("o no")

					err := configurer.Apply(config, netnsFD)
					Expect(err).To(MatchError(&configure.SetNsFailedError{Cause: linkConfigurer.SetNsReturns, Intf: vethCreator.CreateReturns.Container, Netns: netnsFD}))
				})
			})

			Describe("adding the host to the bridge", func() {
				Context("when the bridge interface does not exist", func() {
					It("creates the bridge", func() {
						config.BridgeName = "banana-bridge"
						Expect(configurer.Apply(config, netnsFD)).To(Succeed())
						Expect(bridger.CreateCalledWith.Name).To(Equal("banana-bridge"))
					})

					It("adds the host interface to the created bridge", func() {