chore: production code should not be test aware DHIS2-17821 #18282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our use of
@Conditional
s was wrong IMHO. A@Configuration
for some redis related beans should only care that redis is configured or not or a feature flag being enabled or not. This has nothing to do with it running inside the context of a test.This even impeded our ability to test. This change allows us to setup redis via testcontainers. You could then easily test DHIS2s caching behavior using a controller integration test.
There is also less risk of us not executing a certain logic in production because we messed up a conditional or of how we use profiles.
There are more places like this that we will have to operate on. For example the cache provider configures itself differently or
ArtemisConfig
selects a random port when the test profile is active. Some of these things are already configurable by users via thedhis.conf
.https://dhis2.atlassian.net/browse/DHIS2-17797 will make setting, overriding the default
dhis.conf
in integration tests even easier.