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{} netlinker.LinkListReturns([]netlink.Link{link1, link2}, nil) }) It("returns the links", func() { links, err := factory.ListLinks() Expect(err).NotTo(HaveOccurred()) Expect(links).To(ConsistOf(link1, link2)) }) Context("when listing links fails", func() { BeforeEach(func() { netlinker.LinkListReturns(nil, errors.New("list links failed")) }) It("returns the error", func() { _, err := factory.ListLinks()