コード例 #1
0
		Describe("SetMaster", func() {
			var master, slave netlink.Link
			var masterErr, slaveErr error

			BeforeEach(func() {
				master = &netlink.Bridge{}
				slave = &netlink.Dummy{}
				masterErr = nil
				slaveErr = nil

				netlinker.LinkByNameStub = func(name string) (netlink.Link, error) {
					switch name {
					case "master":
						return master, masterErr
					case "slave":
						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))
コード例 #2
0
	BeforeEach(func() {
		ns = &fakes.Namespace{}
		netlinker = &nl_fakes.Netlinker{}
		logger = lagertest.NewTestLogger("test")
		vxlanLink = &netlink.Vxlan{
			LinkAttrs: netlink.LinkAttrs{
				Index: 9876,
			},
		}

		ns.ExecuteStub = func(callback func(ns *os.File) error) error {
			return callback(nil)
		}

		netlinker.LinkByNameStub = func(linkName string) (netlink.Link, error) {
			return vxlanLink, nil
		}

		inserter = &neigh.ARPInserter{
			Logger:    logger,
			Netlinker: netlinker,
		}
	})

	Describe("HandleResolvedNeighbors", func() {
		var (
			neigh    watcher.Neigh
			neighbor watcher.Neighbor
			resolved chan watcher.Neighbor
			ready    chan error
		)