Fix hanging of version retrieval for manager

pull/219/head
Chip Senkbeil 10 months ago
parent 33f06652dd
commit dc8d8f76cc
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -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))
}

@ -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 {

@ -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),
}
}

@ -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")?
);
}

@ -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("");
}

Loading…
Cancel
Save