It("returns false", func() { Expect(factory.Exists("some-device-name")).To(BeFalse()) Expect(netlinker.LinkByNameCallCount()).To(Equal(1)) Expect(netlinker.LinkByNameArgsForCall(0)).To(Equal("some-device-name")) }) }) }) Describe("DeleteLink", func() { It("deletes the link", func() { link := &netlink.Dummy{} err := factory.DeleteLink(link) Expect(err).NotTo(HaveOccurred()) Expect(netlinker.LinkDelCallCount()).To(Equal(1)) Expect(netlinker.LinkDelArgsForCall(0)).To(Equal(link)) }) Context("when netlink LinkDel fails", func() { BeforeEach(func() { netlinker.LinkDelReturns(errors.New("link del failed")) }) It("returns the error", func() { link := &netlink.Dummy{} err := factory.DeleteLink(link) Expect(err).To(MatchError("link del failed")) }) }) })