示例#1
0
			It("returns a wrapped error", func() {
				linkApplyr.SetMTUReturns = errors.New("this is NOT the right potato")

				config.ContainerIntf = "foo"
				config.Mtu = 1234
				err := configurer.Apply(config)
				Expect(err).To(MatchError(&configure.MTUError{Cause: linkApplyr.SetMTUReturns, Intf: &net.Interface{Name: "foo"}, MTU: 1234}))
			})
		})

		It("adds a default gateway with the requested IP", func() {
			config.ContainerIntf = "foo"
			config.BridgeIP = net.ParseIP("2.3.4.5")
			Expect(configurer.Apply(config)).To(Succeed())
			Expect(linkApplyr.AddDefaultGWCalledWith.Interface).To(Equal(&net.Interface{Name: "foo"}))
			Expect(linkApplyr.AddDefaultGWCalledWith.IP).To(Equal(net.ParseIP("2.3.4.5")))
		})

		Context("when adding a default gateway fails", func() {
			It("returns a wrapped error", func() {
				linkApplyr.AddDefaultGWReturns = errors.New("this is NOT the right potato")

				config.ContainerIntf = "foo"
				config.BridgeIP = net.ParseIP("2.3.4.5")
				err := configurer.Apply(config)
				Expect(err).To(MatchError(&configure.ConfigureDefaultGWError{Cause: linkApplyr.AddDefaultGWReturns, Interface: &net.Interface{Name: "foo"}, IP: net.ParseIP("2.3.4.5")}))
			})
		})
	})
})