It("returns a meaningful error", func() { err := addressManager.AddAddress("my-link", address) Expect(err).To(MatchError("link by name failed: no link for you")) }) }) It("adds an address to the link", func() { err := addressManager.AddAddress("my-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("welp")) }) It("returns the error", func() { err := addressManager.AddAddress("my-link", address) Expect(err).To(MatchError("address add failed: welp")) }) }) }) })