buehler/dotnet-operator-sdk

Accessibility of IManagedResourceController and IControllerInstanceBuilder in test projects

Closed this issue · 1 comments

Describe the bug

I am a newbie to KubeOps and Kubernetes operator. I have a very basic question around the testing. I looked at this link for doing the testing.

If you look at the below two data types they are internal to KubeOps hence not able to use the same in the tests I am creating. I looked at the “KubeOps.TestOperator.Test” sample and it is working because you have added the InternalsVisibleTo attribute to the common.targets.

private readonly IManagedResourceController _controller; .GetRequiredService<IControllerInstanceBuilder>()

Will it be possible for you to suggest the right guidance to move forward with minimal changes here? May be use reflection?

Expected behavior
Successful compilation of Xunit based test projects.

I'm not a big fan of the bottom example on the page; it's just a copy-paste of an internal test for the library.

For your case, there is no need for you to test the internals of the library, only your controller. You should simply resolve your controller directly from the service provider as IResourceController<TEntity> and not worry about the two types you mention.