Describe("SetUp", func() { var link netlink.Link BeforeEach(func() { link = &netlink.Dummy{} netlinker.LinkByNameReturns(link, nil) }) It("sets the link up", func() { err := factory.SetUp("my-link") Expect(err).NotTo(HaveOccurred()) Expect(netlinker.LinkByNameCallCount()).To(Equal(1)) Expect(netlinker.LinkByNameArgsForCall(0)).To(Equal("my-link")) Expect(netlinker.LinkSetUpCallCount()).To(Equal(1)) Expect(netlinker.LinkSetUpArgsForCall(0)).To(Equal(link)) }) 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() {