diff --git a/distant-net/src/manager/client.rs b/distant-net/src/manager/client.rs index fe642b4..f20c700 100644 --- a/distant-net/src/manager/client.rs +++ b/distant-net/src/manager/client.rs @@ -236,7 +236,7 @@ impl ManagerClient { trace!("version()"); let res = self.send(ManagerRequest::Version).await?; match res.payload { - ManagerResponse::Version(version) => Ok(version), + ManagerResponse::Version { version } => Ok(version), ManagerResponse::Error { description } => { Err(io::Error::new(io::ErrorKind::Other, description)) } diff --git a/distant-net/src/manager/data/response.rs b/distant-net/src/manager/data/response.rs index 0a52d23..b48cde5 100644 --- a/distant-net/src/manager/data/response.rs +++ b/distant-net/src/manager/data/response.rs @@ -14,7 +14,7 @@ pub enum ManagerResponse { Error { description: String }, /// Information about the manager's version. - Version(SemVer), + Version { version: SemVer }, /// Confirmation of a server being launched Launched { diff --git a/distant-net/src/manager/server.rs b/distant-net/src/manager/server.rs index 0b8ca27..bf9c504 100644 --- a/distant-net/src/manager/server.rs +++ b/distant-net/src/manager/server.rs @@ -201,7 +201,7 @@ impl ServerHandler for ManagerServer { ManagerRequest::Version {} => { debug!("Looking up version"); match self.version().await { - Ok(version) => ManagerResponse::Version(version), + Ok(version) => ManagerResponse::Version { version }, Err(x) => ManagerResponse::from(x), } } diff --git a/src/cli/commands/manager.rs b/src/cli/commands/manager.rs index f65c9f0..a75394f 100644 --- a/src/cli/commands/manager.rs +++ b/src/cli/commands/manager.rs @@ -240,7 +240,7 @@ async fn async_run(cmd: ManagerSubcommand) -> CliResult { Format::Json => { println!( "{}", - serde_json::to_string(&version) + serde_json::to_string(&serde_json::json!({ "version": version })) .context("Failed to format version as json")? ); } diff --git a/tests/cli/manager/version.rs b/tests/cli/manager/version.rs index 8013609..40038fb 100644 --- a/tests/cli/manager/version.rs +++ b/tests/cli/manager/version.rs @@ -5,21 +5,9 @@ use crate::common::fixtures::*; #[rstest] #[test_log::test] fn should_output_version(ctx: DistantManagerCtx) { - // distant action capabilities ctx.new_assert_cmd(vec!["manager", "version"]) .assert() .success() - .stdout("WRONG") - .stderr(""); -} - -#[rstest] -#[test_log::test] -fn should_support_output_version_as_json(ctx: DistantManagerCtx) { - // distant action capabilities - ctx.new_assert_cmd(vec!["manager", "version", "--format", "json"]) - .assert() - .success() - .stdout("WRONG") + .stdout(format!("{}\n", env!("CARGO_PKG_VERSION"))) .stderr(""); }