mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
feat: prepare 3.0.0 release
This commit is contained in:
252 files changed
+26210
-7457
No files matched your search
@@ -0,0 +1,41 @@
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(super) enum ScriptSource<'a> {
|
||||
Installed(&'a Path),
|
||||
Legacy(&'a str),
|
||||
Default,
|
||||
}
|
||||
|
||||
pub(super) fn select<'a>(installed: Option<&'a Path>, legacy: Option<&'a str>) -> ScriptSource<'a> {
|
||||
if let Some(path) = installed {
|
||||
return ScriptSource::Installed(path);
|
||||
}
|
||||
if let Some(script) = legacy {
|
||||
return ScriptSource::Legacy(script);
|
||||
}
|
||||
ScriptSource::Default
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn installed_script_takes_precedence_over_legacy() {
|
||||
let installed = Path::new("/var/lib/gpclient/scripts/vpnc-script");
|
||||
assert_eq!(
|
||||
select(Some(installed), Some("legacy-command")),
|
||||
ScriptSource::Installed(installed)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_script_is_used_before_default() {
|
||||
assert_eq!(
|
||||
select(None, Some("legacy-command")),
|
||||
ScriptSource::Legacy("legacy-command")
|
||||
);
|
||||
assert_eq!(select(None, None), ScriptSource::Default);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user