This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add proper error handling to setup command (#452)
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
mod utils; | ||
|
||
use std::process::Command; | ||
|
||
use assert_cmd::prelude::*; | ||
use tempfile::tempdir; | ||
|
||
#[test] | ||
fn setup_subnet_install_edge() -> Result<(), Box<dyn std::error::Error>> { | ||
let tmp_home_dir = tempdir()?; | ||
|
||
let mut cmd = Command::cargo_bin("topos")?; | ||
cmd.arg("setup") | ||
.arg("subnet") | ||
.arg("--path") | ||
.arg(tmp_home_dir.path()); | ||
|
||
let output = cmd.assert().success(); | ||
|
||
let result: &str = std::str::from_utf8(&output.get_output().stdout)?; | ||
|
||
assert!(result.contains("Polygon Edge installation successful")); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn setup_with_no_arguments() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut cmd = Command::cargo_bin("topos")?; | ||
cmd.arg("setup"); | ||
|
||
let output = cmd.assert().failure(); | ||
|
||
let result: &str = std::str::from_utf8(&output.get_output().stderr)?; | ||
|
||
assert!(result | ||
.contains("No subcommand provided. You can use `--help` to see available subcommands.")); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn setup_subnet_fail_to_install_release() -> Result<(), Box<dyn std::error::Error>> { | ||
let tmp_home_dir = tempdir()?; | ||
|
||
let mut cmd = Command::cargo_bin("topos")?; | ||
cmd.arg("setup") | ||
.arg("subnet") | ||
.arg("--path") | ||
.arg(tmp_home_dir.path()) | ||
.arg("--release") | ||
.arg("invalid"); | ||
|
||
let output = cmd.assert().failure(); | ||
|
||
let result: &str = std::str::from_utf8(&output.get_output().stderr)?; | ||
|
||
assert!(result.contains( | ||
"Error installing Polygon Edge: There is no valid Polygon Edge release available" | ||
)); | ||
|
||
Ok(()) | ||
} |