Refactoring: Remove `localClient` global Variable in `remote` pkg
Closed this issue · 0 comments
Description
To have some of our code testable in EnvTest, we introduced a global variable called localClient
in the remote
package.
But, we should not have production ready code including code which is just used for testing, instead the code should be written in a way that it is testable without such modifications.
The global var localClient
is set during EnvTests when creating a new SKRCluster, and thus when the LifecycleManager tries to resolve the SKRClient, it instead used the set localClient
. With the current implementation each test scenario using the NewSKRCluster
func runs in its own virtual SKR cluster, it would be great to keep such behaviour to have separated test cases.
The initializeKymaContext
is a standalone function, but it could be a method on a new i.e. RemoteClientFactory (explicit deps on Kyma reconciler; new interface). The dependency could be replaced in the envTest with a Factory returning the localClient instead of SKR Client.
Reasons
- Not have test code in production.
- Reduce tech dept.
- Avoided unwanted behaviour by overwriting the global variable.
Acceptance Criteria
- Refactor the implementation of
restConfigFromStrategy
in such a way that it does not use a global variable to determine if a localClient should be used - Adapt test suits
- Test cases should still run in own virtual SKR cluster
Feature Testing
Integration tests
Testing approach
No response
Attachments
No response