-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: make factory registries support injection #1976
Conversation
Signed-off-by: Alex Konradi <[email protected]>
Signed-off-by: Alex Konradi <[email protected]>
Don't de-register factories on shutdown since that's not necessary. Signed-off-by: Alex Konradi <[email protected]>
Signed-off-by: Alex Konradi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff. Small nit. @alyssawilk FWIW I like this pattern of having an RAII guard around replacing statics for tests. I haven't looked at your other PR but maybe we can do this for that also somehow?
include/envoy/registry/registry.h
Outdated
@@ -36,6 +36,17 @@ template <class Base> class FactoryRegistry { | |||
} | |||
|
|||
/** | |||
* Replaces a factory by name. This method should only be used for testing purposes. | |||
* @param factory is the factory to inject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: periods end of sentences here and below.
@mattklein123 I do have an RAII replacement for tests. It's the Singleton itself which isn't of limited scope, right? |
Signed-off-by: Alex Konradi <[email protected]>
@alyssawilk right, cool. Will look at the other PR. |
Make InjectFactory a friend of the FactoryRegistry class, and limit access to the testing functions by making them private. Signed-off-by: Alex Konradi <[email protected]>
Signed-off-by: Alex Konradi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @htuch or @alyssawilk any comments?
Changes makeEnvoyMap to work with not only a vector of pairs, but any map-like container type. Signed-off-by: Snow Pettersen <[email protected]> Risk Level: Low Testing: Existing tests Docs Changes: n/a Release Notes: n/a Signed-off-by: JP Simard <[email protected]>
Changes makeEnvoyMap to work with not only a vector of pairs, but any map-like container type. Signed-off-by: Snow Pettersen <[email protected]> Risk Level: Low Testing: Existing tests Docs Changes: n/a Release Notes: n/a Signed-off-by: JP Simard <[email protected]>
Description:
Allows factories to be injected into registries for testing purpoes.
Tangentially related to #1808
Risk Level: Low
Testing:
Ran the unit tests