BeforeEach(func() { var err error link = &netlink.Veth{} _, address, err = net.ParseCIDR("192.168.1.1/24") Expect(err).NotTo(HaveOccurred()) }) It("adds an address to the link", func() { err := addressManager.AddAddress(link, address) Expect(err).NotTo(HaveOccurred()) Expect(netlinker.AddrAddCallCount()).To(Equal(1)) actualLink, netlinkAddr := netlinker.AddrAddArgsForCall(0) Expect(actualLink).To(Equal(link)) Expect(netlinkAddr.IPNet).To(Equal(address)) }) Context("when adding the addres fails", func() { BeforeEach(func() { netlinker.AddrAddReturns(errors.New("adding address failed")) }) It("returns the error", func() { err := addressManager.AddAddress(link, address) Expect(err).To(MatchError("adding address failed")) }) }) }) })
}) }) It("assigns the specified address", func() { _, err := factory.CreateBridge("some-bridge-name", address) Expect(err).NotTo(HaveOccurred()) Expect(netlinker.AddrAddCallCount()).To(Equal(1)) br, addr := netlinker.AddrAddArgsForCall(0) Expect(br).To(Equal(expectedBridge)) Expect(addr).To(Equal(&netlink.Addr{IPNet: address})) }) Context("when assigning an address to the bridge fails", func() { It("returns the error", func() { netlinker.AddrAddReturns(errors.New("addr add failed")) _, err := factory.CreateBridge("some-bridge-name", address) Expect(err).To(Equal(errors.New("addr add failed"))) }) }) It("sets the bridge link up", func() { _, err := factory.CreateBridge("some-bridge-name", address) Expect(err).NotTo(HaveOccurred()) Expect(netlinker.LinkSetUpCallCount()).To(Equal(1)) Expect(netlinker.LinkSetUpArgsForCall(0)).To(Equal(expectedBridge)) }) Context("when setting the bridge link up fails", func() {