Context("when finding the link fails", func() { BeforeEach(func() { netlinker.LinkByNameReturns(nil, errors.New("no link for you")) }) It("returns a meaningful error", func() { err := routeManager.AddRoute("my-link", network, gateway) Expect(err).To(MatchError("link by name failed: no link for you")) }) }) It("adds a route", func() { err := routeManager.AddRoute("my-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("welp")) })