diff options
author | PradeepKiruvale <PRADEEPKIRUVALE@gmail.com> | 2021-09-13 18:06:05 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 18:06:05 +0530 |
commit | d5489e20ce33c46a5d667973bb1f245e41e77b2f (patch) | |
tree | b7ad88415ef1db1cf3a02fc079a05a367dd62a65 | |
parent | cea1f56a29171c622b28cd333045aac7e0a3da9c (diff) |
[cit-551] fix tarpaulin tests (#423)
* fix tarpaulin tests
* address review comments
Co-authored-by: Pradeep Kumar K J <pradeepkumar.kj@sofwareag.com>
-rw-r--r-- | sm/plugin_sm/src/plugin.rs | 11 | ||||
-rw-r--r-- | sm/plugin_sm/tests/plugin.rs | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sm/plugin_sm/src/plugin.rs b/sm/plugin_sm/src/plugin.rs index e285d8d8..ae1331de 100644 --- a/sm/plugin_sm/src/plugin.rs +++ b/sm/plugin_sm/src/plugin.rs @@ -49,6 +49,7 @@ pub trait Plugin { pub struct ExternalPluginCommand { pub name: SoftwareType, pub path: PathBuf, + pub sudo: Option<PathBuf>, } impl ExternalPluginCommand { @@ -56,6 +57,7 @@ impl ExternalPluginCommand { ExternalPluginCommand { name: name.into(), path: path.into(), + sudo: Some("sudo".into()), } } @@ -64,8 +66,13 @@ impl ExternalPluginCommand { action: &str, maybe_module: Option<&SoftwareModule>, ) -> Result<Command, SoftwareError> { - let mut command = Command::new("sudo"); - command.arg(&self.path); + let mut command = if let Some(sudo) = &self.sudo { + let mut command = Command::new(&sudo); + command.arg(&self.path); + command + } else { + Command::new(&self.path) + }; command.arg(action); if let Some(module) = maybe_module { diff --git a/sm/plugin_sm/tests/plugin.rs b/sm/plugin_sm/tests/plugin.rs index 2679852c..138b06ab 100644 --- a/sm/plugin_sm/tests/plugin.rs +++ b/sm/plugin_sm/tests/plugin.rs @@ -214,7 +214,11 @@ mod tests { fn get_dummy_plugin(name: &str) -> (ExternalPluginCommand, PathBuf) { let dummy_plugin_path = get_dummy_plugin_path(); - let plugin = ExternalPluginCommand::new(name, &dummy_plugin_path); + let plugin = ExternalPluginCommand { + name: name.into(), + path: dummy_plugin_path.clone().into(), + sudo: None, + }; (plugin, dummy_plugin_path) } |