Check if an installed version is compatible with the expected version. Returns true if the installed version is greater than or equal to the expected version. Logs warnings for outdated or experimental versions.
(command: &str, installed: &Version, expected: &Version)
| 21 | /// Returns true if the installed version is greater than or equal to the expected version. |
| 22 | /// Logs warnings for outdated or experimental versions. |
| 23 | pub(super) fn is_compatible(command: &str, installed: &Version, expected: &Version) -> bool { |
| 24 | match installed.cmp(expected) { |
| 25 | std::cmp::Ordering::Less => { |
| 26 | warn!( |
| 27 | "{command} is installed but the version is too old. expecting {expected} or higher but found installed: {installed}", |
| 28 | ); |
| 29 | false |
| 30 | } |
| 31 | std::cmp::Ordering::Greater => { |
| 32 | warn!( |
| 33 | "Using experimental {command} version {installed}. The recommended version is {expected}", |
| 34 | ); |
| 35 | true |
| 36 | } |
| 37 | std::cmp::Ordering::Equal => true, |
| 38 | } |
| 39 | } |
| 40 | #[cfg(test)] |
| 41 | mod tests { |
| 42 | use super::*; |
no outgoing calls
no test coverage detected