Exemplo n.º 1
0
			Expect(err).NotTo(HaveOccurred())
		})

		It("adds a route", func() {
			err := routeManager.AddRoute(link, network, gateway)
			Expect(err).NotTo(HaveOccurred())

			Expect(netlinker.RouteAddCallCount()).To(Equal(1))
			route := netlinker.RouteAddArgsForCall(0)

			Expect(route).To(Equal(&netlink.Route{
				LinkIndex: 999,
				Scope:     netlink.SCOPE_UNIVERSE,
				Dst:       network,
				Gw:        gateway,
			}))
		})

		Context("when adding the route fails", func() {
			BeforeEach(func() {
				netlinker.RouteAddReturns(errors.New("route add failed"))
			})

			It("returns the error", func() {
				err := routeManager.AddRoute(link, network, gateway)
				Expect(err).To(MatchError("route add failed"))
			})
		})
	})
})