}) Context("when finding the link fails", func() { BeforeEach(func() { netlinker.LinkByNameReturns(nil, errors.New("can't find it")) }) It("returns the error", func() { err := factory.DeleteLinkByName("test-link") Expect(err).To(MatchError("can't find it")) }) }) Context("when setting the link up fails", func() { BeforeEach(func() { netlinker.LinkSetUpReturns(errors.New("I've fallen and I can't get up")) }) It("returns a meaningful error", func() { err := factory.SetUp("my-link") Expect(err).To(MatchError("failed to set link up: I've fallen and I can't get up")) }) }) }) Describe("ListLinks", func() { var link1, link2 netlink.Link BeforeEach(func() { link1 = &netlink.Dummy{} link2 = &netlink.Veth{}