summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPradeepKiruvale <PRADEEPKIRUVALE@gmail.com>2021-09-13 18:06:05 +0530
committerGitHub <noreply@github.com>2021-09-13 18:06:05 +0530
commitd5489e20ce33c46a5d667973bb1f245e41e77b2f (patch)
treeb7ad88415ef1db1cf3a02fc079a05a367dd62a65
parentcea1f56a29171c622b28cd333045aac7e0a3da9c (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.rs11
-rw-r--r--sm/plugin_sm/tests/plugin.rs6
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)
}