pub trait ServiceControl: Sync {
// Required methods
fn create_service_user(&self, username: &str) -> Result<()>;
fn get_available_port(&self) -> Result<u16>;
fn install(
&self,
install_ctx: ServiceInstallCtx,
user_mode: bool,
) -> Result<()>;
fn get_process_pid(&self, path: &Path) -> Result<u32>;
fn start(&self, service_name: &str, user_mode: bool) -> Result<()>;
fn stop(&self, service_name: &str, user_mode: bool) -> Result<()>;
fn uninstall(&self, service_name: &str, user_mode: bool) -> Result<()>;
fn wait(&self, delay: u64);
}Expand description
A thin wrapper around the service_manager::ServiceManager, which makes our own testing
easier.
We can make an assumption that this external component works correctly, so our own tests only need assert that the service manager is used. Testing code that used the real service manager would result in real services on the machines we are testing on; that can leave a bit of a mess to clean up, especially if the tests fail.