Example #1
0
func (p *FakeNetworkPool) Remove(network *network.Network) error {
	if p.RemoveError != nil {
		return p.RemoveError
	}

	p.Removed = append(p.Removed, network.String())

	return nil
}
Example #2
0
func (p *RealNetworkPool) Remove(network *network.Network) error {
	idx := 0
	found := false

	p.poolMutex.Lock()
	defer p.poolMutex.Unlock()

	for i, existingNetwork := range p.pool {
		if existingNetwork.String() == network.String() {
			idx = i
			found = true
			break
		}
	}

	if !found {
		return NetworkTakenError{network}
	}

	p.pool = append(p.pool[:idx], p.pool[idx+1:]...)

	return nil
}
				"some-other-restored-event",
			}))
		})

		It("removes its UID from the pool", func() {
			_, err := pool.Restore(snapshot)
			Expect(err).ToNot(HaveOccurred())

			Expect(fakeUIDPool.Removed).To(ContainElement(uint32(10000)))
		})

		It("removes its network from the pool", func() {
			_, err := pool.Restore(snapshot)
			Expect(err).ToNot(HaveOccurred())

			Expect(fakeNetworkPool.Removed).To(ContainElement(restoredNetwork.String()))
		})

		It("removes its ports from the pool", func() {
			_, err := pool.Restore(snapshot)
			Expect(err).ToNot(HaveOccurred())

			Expect(fakePortPool.Removed).To(ContainElement(uint32(61001)))
			Expect(fakePortPool.Removed).To(ContainElement(uint32(61002)))
			Expect(fakePortPool.Removed).To(ContainElement(uint32(61003)))
		})

		Context("when decoding the snapshot fails", func() {
			BeforeEach(func() {
				snapshot = new(bytes.Buffer)
			})
Example #4
0
func (p *FakeNetworkPool) Release(network *network.Network) {
	p.Released = append(p.Released, network.String())
}