Skip to content

Commit

Permalink
fixup! Check that the daemon version is correct post-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Nov 4, 2024
1 parent d1311d0 commit 98780cb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
16 changes: 16 additions & 0 deletions mullvad-version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Display;
use std::str::FromStr;
use std::sync::LazyLock;

Expand All @@ -19,6 +20,21 @@ impl Version {
}
}

impl Display for Version {
/// Format Version as a string: year.incremental{-beta}
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Version {
year,
incremental,
beta,
} = &self;
match beta {
Some(beta) => write!(f, "{year}.{incremental}-{beta}"),
None => write!(f, "{year}.{incremental}"),
}
}
}

impl FromStr for Version {
type Err = String;

Expand Down
7 changes: 5 additions & 2 deletions test/test-manager/src/tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ pub async fn test_upgrade_app(
// Verify that the correct version was installed
// TODO: Verify that `app_package_filename` is the expected app version.
let running_daemon_version = rpc.mullvad_daemon_version().await?;
let running_daemon_version =
mullvad_version::Version::parse(&running_daemon_version).to_string();
ensure!(
mullvad_version::Version::parse(&running_daemon_version)
== mullvad_version::Version::parse(&TEST_CONFIG.app_package_filename),
&TEST_CONFIG
.app_package_filename
.contains(&running_daemon_version),
Error::DaemonVersion {
expected: TEST_CONFIG.app_package_filename.clone(),
actual: running_daemon_version,
Expand Down
8 changes: 8 additions & 0 deletions test/test-runner/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ pub async fn version() -> Result<String, Error> {
.await
.map_err(|e| Error::Service(e.to_string()))?;
let version = String::from_utf8(version.stdout).map_err(|err| Error::Other(err.to_string()))?;
// HACK: The output from `mullvad --version` includes the `mullvad-cli` binary name followed by
// the version string. Simply remove the leading noise and get at the version string.
let Some(version) = version.split_whitespace().nth(1) else {
return Err(Error::Other(
"Could not parse version number from `mullvad-cli --version`".to_string(),
));
};
let version = version.to_string();
Ok(version)
}

Expand Down

0 comments on commit 98780cb

Please sign in to comment.