Skip to content
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

Merged
merged 7 commits into from
Nov 1, 2017

Conversation

akonradi
Copy link
Contributor

Description:
Allows factories to be injected into registries for testing purpoes.

Tangentially related to #1808

Risk Level: Low

Testing:
Ran the unit tests

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]>
Copy link
Member

@mattklein123 mattklein123 left a 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?

@@ -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
Copy link
Member

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.

@alyssawilk
Copy link
Contributor

@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]>
@mattklein123
Copy link
Member

@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]>
Copy link
Member

@mattklein123 mattklein123 left a 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?

@alyssawilk alyssawilk merged commit b386841 into envoyproxy:master Nov 1, 2017
@akonradi akonradi deleted the factory-injection branch November 1, 2017 13:44
jpsim pushed a commit that referenced this pull request Nov 28, 2022
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]>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants