}) Context("when finding the link fails", func() { BeforeEach(func() { netlinker.LinkByNameReturns(nil, errors.New("no link for you")) }) It("returns a meaningful error", func() { err := factory.SetNamespace("link-name", 99) Expect(err).To(MatchError("failed to find link: no link for you")) }) }) Context("when assigning the namespace fails", func() { BeforeEach(func() { netlinker.LinkSetNsFdReturns(errors.New("what namespace?")) }) It("returns a meaningful error", func() { err := factory.SetNamespace("link-name", 99) Expect(err).To(MatchError("failed to set link namespace: what namespace?")) }) }) }) Describe("HardwareAddress", func() { var ( expectedHwAddr net.HardwareAddr link *netlink.Dummy )