Context("when finding the slave link fails", func() { BeforeEach(func() { slaveErr = errors.New("po-tah-toe") }) It("wraps and returns the error", func() { err := factory.SetMaster("slave", "master") Expect(err).To(MatchError("failed to find slave: po-tah-toe")) }) }) Context("when enslaving fails", func() { BeforeEach(func() { netlinker.LinkSetMasterReturns(errors.New("you're not a slave")) }) It("returns a meaningful error", func() { err := factory.SetMaster("slave", "master") Expect(err).To(MatchError("failed to set master: you're not a slave")) }) }) }) Describe("SetNamespace", func() { var link netlink.Link BeforeEach(func() { link = &netlink.Dummy{} netlinker.LinkByNameReturns(link, nil)