Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
refactor: 'JsonOutput' -> 'Output'
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
  • Loading branch information
vados-cosmonic committed Jun 1, 2023
1 parent 569c0c4 commit 4cce76b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions crates/wash-lib/src/cli/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use wasmcloud_control_interface::{GetClaimsResponse, Host, HostInventory};

/// JSON Output of the `wash start` command
#[derive(Debug, Deserialize)]
pub struct StartCommandJsonOutput {
pub struct StartCommandOutput {
pub actor_id: Option<String>,
pub actor_ref: Option<String>,

Expand All @@ -21,7 +21,7 @@ pub struct StartCommandJsonOutput {

/// JSON Output representation of the `wash stop` command
#[derive(Debug, Deserialize)]
pub struct StopCommandJsonOutput {
pub struct StopCommandOutput {
pub host_id: Option<String>,
pub result: String,

Expand All @@ -38,28 +38,28 @@ pub struct StopCommandJsonOutput {

/// JSON output representation of the `wash link query` command
#[derive(Debug, Deserialize)]
pub struct LinkQueryJsonOutput {
pub struct LinkQueryOutput {
pub links: Vec<HashMap<String, ActorLinks>>,
pub success: bool,
}

/// JSON output representation of the `wash get hosts` command
#[derive(Debug, Clone, Deserialize)]
pub struct GetHostsJsonOutput {
pub struct GetHostsOutput {
pub success: bool,
pub hosts: Vec<Host>,
}

/// JSON output representation of the `wash get inventory` command
#[derive(Debug, Clone, Deserialize)]
pub struct GetHostInventoryJsonOutput {
pub struct GetHostInventoryOutput {
pub success: bool,
pub inventory: HostInventory,
}

/// JSON output representation of the `wash get claims` command
#[derive(Debug, Deserialize)]
pub struct GetClaimsJsonOutput {
pub struct GetClaimsOutput {
pub claims: GetClaimsResponse,
pub success: bool,
}
10 changes: 5 additions & 5 deletions tests/integration_get.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use serial_test::serial;
use wash_lib::cli::output::{
GetClaimsJsonOutput, GetHostInventoryJsonOutput, GetHostsJsonOutput, LinkQueryJsonOutput,
GetClaimsOutput, GetHostInventoryOutput, GetHostsOutput, LinkQueryOutput,
};

mod common;
Expand All @@ -19,7 +19,7 @@ async fn integration_get_hosts() -> Result<()> {

assert!(output.status.success(), "executed get hosts query");

let cmd_output: GetHostsJsonOutput = serde_json::from_slice(&output.stdout)?;
let cmd_output: GetHostsOutput = serde_json::from_slice(&output.stdout)?;
assert!(cmd_output.success, "command returned success");
assert_eq!(cmd_output.hosts.len(), 1, "hosts contains one host");
assert_eq!(
Expand All @@ -42,7 +42,7 @@ async fn integration_get_links() -> Result<()> {

assert!(output.status.success(), "executed get links query");

let cmd_output: LinkQueryJsonOutput = serde_json::from_slice(&output.stdout)?;
let cmd_output: LinkQueryOutput = serde_json::from_slice(&output.stdout)?;
assert!(cmd_output.success, "command returned success");
assert_eq!(cmd_output.links.len(), 0, "links list is empty");

Expand All @@ -67,7 +67,7 @@ async fn integration_get_host_inventory() -> Result<()> {

assert!(output.status.success(), "executed get inventory");

let cmd_output: GetHostInventoryJsonOutput = serde_json::from_slice(&output.stdout)?;
let cmd_output: GetHostInventoryOutput = serde_json::from_slice(&output.stdout)?;
assert!(cmd_output.success, "command returned success");

assert!(
Expand Down Expand Up @@ -117,7 +117,7 @@ async fn integration_get_claims() -> Result<()> {

assert!(output.status.success(), "executed get claims query");

let cmd_output: GetClaimsJsonOutput = serde_json::from_slice(&output.stdout)?;
let cmd_output: GetClaimsOutput = serde_json::from_slice(&output.stdout)?;
assert!(cmd_output.success, "command returned success");

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_link.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{Context, Result};
use serial_test::serial;
use wash_lib::cli::output::LinkQueryJsonOutput;
use wash_lib::cli::output::LinkQueryOutput;

mod common;
use common::{wash, TestWashInstance};
Expand All @@ -17,7 +17,7 @@ async fn integration_link() -> Result<()> {

assert!(output.status.success(), "executed link query");

let cmd_output: LinkQueryJsonOutput = serde_json::from_slice(&output.stdout)?;
let cmd_output: LinkQueryOutput = serde_json::from_slice(&output.stdout)?;
assert!(cmd_output.success, "command returned success");
assert_eq!(
cmd_output.links.len(),
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_start.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{Context, Result};
use serial_test::serial;
use wash_lib::cli::output::StartCommandJsonOutput;
use wash_lib::cli::output::StartCommandOutput;

mod common;
use common::{wash, TestWashInstance, ECHO_OCI_REF, PROVIDER_HTTPSERVER_OCI_REF};
Expand All @@ -25,7 +25,7 @@ async fn integration_start_actor() -> Result<()> {

assert!(output.status.success(), "executed start");

let cmd_output: StartCommandJsonOutput =
let cmd_output: StartCommandOutput =
serde_json::from_slice(&output.stdout).context("failed to parse output")?;
assert!(cmd_output.success, "command returned success");

Expand All @@ -52,7 +52,7 @@ async fn integration_start_provider() -> Result<()> {

assert!(output.status.success(), "executed start");

let cmd_output: StartCommandJsonOutput =
let cmd_output: StartCommandOutput =
serde_json::from_slice(&output.stdout).context("failed to parse output")?;
assert!(cmd_output.success, "command returned success");

Expand Down
12 changes: 6 additions & 6 deletions tests/integration_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serial_test::serial;

mod common;
use common::{wash, TestWashInstance, ECHO_OCI_REF, PROVIDER_HTTPSERVER_OCI_REF};
use wash_lib::cli::output::{StartCommandJsonOutput, StopCommandJsonOutput};
use wash_lib::cli::output::{StartCommandOutput, StopCommandOutput};

#[tokio::test]
#[serial]
Expand All @@ -24,7 +24,7 @@ async fn integration_stop_actor() -> Result<()> {
.context("failed to start actor")?;
assert!(output.status.success(), "executed start");

let StartCommandJsonOutput {
let StartCommandOutput {
actor_id,
actor_ref,
host_id,
Expand All @@ -46,7 +46,7 @@ async fn integration_stop_actor() -> Result<()> {

assert!(output.status.success(), "executed stop");

let cmd_output: StopCommandJsonOutput =
let cmd_output: StopCommandOutput =
serde_json::from_slice(&output.stdout).context("failed to parse stop output")?;
assert!(cmd_output.success, "command returned success");

Expand All @@ -72,7 +72,7 @@ async fn integration_stop_provider() -> Result<()> {
.context("failed to start actor")?;
assert!(output.status.success(), "executed start");

let StartCommandJsonOutput {
let StartCommandOutput {
provider_id,
provider_ref,
host_id,
Expand Down Expand Up @@ -109,7 +109,7 @@ async fn integration_stop_provider() -> Result<()> {

assert!(output.status.success(), "executed stop");

let cmd_output: StopCommandJsonOutput =
let cmd_output: StopCommandOutput =
serde_json::from_slice(&output.stdout).context("failed to parse stop output")?;
assert!(cmd_output.success, "command returned success");

Expand All @@ -128,7 +128,7 @@ async fn integration_stop_host() -> Result<()> {

assert!(output.status.success(), "executed stop");

let cmd_output: StopCommandJsonOutput =
let cmd_output: StopCommandOutput =
serde_json::from_slice(&output.stdout).context("failed to parse output")?;
assert!(cmd_output.success, "command returned success");

Expand Down

0 comments on commit 4cce76b

Please sign in to comment.