Is it okay to run go test as root?

I am writing Unit Test for my enterprise application software where I have to test a package which loads/unloads a few OSx daemons( /Library/LaunchDaemon/my.temp.service.plist). this daemon can only be controlled as the root user.
Is there a way to write Unit Test for the daemonControlManager package?
Is it advisable to run go test as root? if yes then how can I selectively run my go test as root only when running UT for only this package?

The proper way would probably be to not actually start/stop the real service, but use mocks/stubs to test if it would be started/stopped.

If you need real integration tests starting and stopping the service some container or dedicated VM, just spun up for the tests and shut down/deleted after the tests would be the optimal way to go.



This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.