fakeNetlinker = &nlfakes.Netlinker{} fakeSocket = &nlfakes.NLSocket{} neighChan = make(chan *watcher.Neigh, 100) doneChan = make(chan struct{}) logger = lagertest.NewTestLogger("test") targetNS = &fakes.Namespace{} targetNS.ExecuteStub = func(callback func(*os.File) error) error { return callback(nil) } mySubscriber = &subscriber.Subscriber{ Netlinker: fakeNetlinker, Logger: logger, } fakeNetlinker.SubscribeReturns(fakeSocket, nil) fakeSocket.ReceiveReturns([]syscall.NetlinkMessage{{Data: []byte("something")}}, nil) fakeNetlinker.NeighDeserializeReturns(&netlink.Neigh{}, nil) }) It("subscribes in the sandbox namespace", func() { targetNS.ExecuteStub = func(callback func(*os.File) error) error { defer GinkgoRecover() Expect(fakeNetlinker.SubscribeCallCount()).To(Equal(0)) err := callback(nil) Expect(fakeNetlinker.SubscribeCallCount()).To(Equal(1)) return err } err := mySubscriber.Subscribe(targetNS, neighChan, doneChan) Expect(err).NotTo(HaveOccurred())