return slave, slaveErr
					default:
						return nil, errors.New("unknown")
					}
				}
			})

			It("sets the slave's master", func() {
				err := factory.SetMaster("slave", "master")
				Expect(err).NotTo(HaveOccurred())

				Expect(netlinker.LinkByNameCallCount()).To(Equal(2))
				Expect(netlinker.LinkByNameArgsForCall(0)).To(Equal("master"))
				Expect(netlinker.LinkByNameArgsForCall(1)).To(Equal("slave"))

				Expect(netlinker.LinkSetMasterCallCount()).To(Equal(1))
				s, m := netlinker.LinkSetMasterArgsForCall(0)
				Expect(s).To(Equal(slave))
				Expect(m).To(Equal(master))
			})

			Context("when finding the master link fails", func() {
				BeforeEach(func() {
					masterErr = errors.New("potato")
				})

				It("wraps and returns the error", func() {
					err := factory.SetMaster("slave", "master")
					Expect(err).To(MatchError("failed to find master: potato"))
				})
			})