Skip to content

Commit

Permalink
Merge pull request #175 from Screenly/test/add_instance_formatter
Browse files Browse the repository at this point in the history
Test/add instance formatter
  • Loading branch information
korvyashka authored Jul 4, 2024
2 parents d31fcc3 + c630298 commit fa89418
Showing 1 changed file with 30 additions and 43 deletions.
73 changes: 30 additions & 43 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,46 +576,33 @@ impl Formatter for PlaylistItems {
}
}

// #[cfg(test)]
// mod tests {
// use super::*;

// #[test]
// fn test_edge_app_versions_formatter_format_output_properly() {
// let data = r#"[{
// "edge_app_channels": [
// {
// "channel": "stable"
// },
// {
// "channel": "candidate"
// }
// ],
// "revision": 1,
// "user_version": "1.0.0",
// "description": "Initial release",
// "published": true
// },
// {
// "edge_app_channels": [],
// "revision": 2,
// "user_version": "1.0.1",
// "description": "Bug fixes",
// "published": true
// }]"#;
// let edge_app_versions = EdgeAppVersions::new(serde_json::from_str(data).unwrap());
//
// let output = edge_app_versions.format(OutputType::HumanReadable);
// assert_eq!(
// output,
// r#"+----------+-----------------+-----------+-------------------+
// | Revision | Description | Published | Channels |
// +----------+-----------------+-----------+-------------------+
// | 1 | Initial release | ✅ | stable, candidate |
// +----------+-----------------+-----------+-------------------+
// | 2 | Bug fixes | ✅ | |
// +----------+-----------------+-----------+-------------------+
// "#
// );
// }
// }
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_edge_app_instance_formatter_format_output_properly() {
let data = r#"[{
"id": "01J1SNE1GMGG8R0ZXZ183ZGN6T",
"name": "Test App"
},
{
"id": "01J1SNE1GMGG8R0ZXZ183ZGN7T",
"name": "Test App 2"
}]"#;
let edge_app_instances = EdgeAppInstances::new(serde_json::from_str(data).unwrap());

let output = edge_app_instances.format(OutputType::HumanReadable);
assert_eq!(
output,
r#"+----------------------------+------------+
| Id | Name |
+----------------------------+------------+
| 01J1SNE1GMGG8R0ZXZ183ZGN6T | Test App |
+----------------------------+------------+
| 01J1SNE1GMGG8R0ZXZ183ZGN7T | Test App 2 |
+----------------------------+------------+
"#
);
}
}

0 comments on commit fa89418

Please sign in to comment.