netops::Dispatcher
Summary: Wrapper around `folly::netops` methods that makes it easier to mock these methods in unit tests. When we want to mock out calls to `folly::netops` we currently: - Use methods like `getSockOptVirtual` and `setSockOptVirtual` - Mock part of the socket, like in the tests in `AsyncSSLSocketWriteTest` I've the latter makes the tests particularly error prone, since we're mocking the object that's also under test. This change introduces `netops::Dispatcher`, which is a class containing all of the functions in `folly::netops`: - By default `AsyncSocket` uses a default, static instance of `Dispatcher` that forwards calls to the original `netops::` calls (e.g., calling `netops::Dispatcher::sendmsg` results in a call to `netops::sendmsg`. - When a test wants to mock a a `folly::netops` call, it can call `setOverrideNetOpsDispatcher` to insert a mock `netops::Dispatcher`. I use it in this manner in D24094832 Differential Revision: D24661160 fbshipit-source-id: e9cb4ed28ffe409c74998a1c9501c0706fc853e0
Showing
folly/net/NetOpsDispatcher.h
0 → 100644
Please register or sign in to comment